Undefined results when using getCoupon()

Trying to get the details for a coupon (SAMPLE$1OFF, created on Wix and visible in the Wix Coupons db) by using getCoupon() with the coupon _id as a parameter. Not sure where I’m going wrong, but the console results just show everything returned as “undefined”.

type or paste code here

Backend file GetCoupon.jsw

import { coupons } from 'wix-marketing.v2';
  
 export async function getCoupon(id) {
   try {
     const result = await coupons.getCoupon(id);
     return result;
   } catch (error) {
     console.log(error);
   }
 }

and the front-end call:


import {getCoupon} from 'backend/GetCoupon.jsw';

$w.onReady(function () {

let testCoupon = "1cc6a9bc-ed7b-4f8b-9650-93ffebc6340c" //SAMPLE$1OFF COUPON _id
getCoupon(testCoupon)
    .then(results => {
      let coupon = results
      console.log("coupon name is:" + coupon.name);
      console.log("coupon code is:" + coupon.code);
      console.log("coupon money off amount is: " + coupon.moneyOffAmount);
      console.log("coupon percent amount off is: " + coupon.percentOffRate);
      })
    .catch(error => {
        console.log(error);
    });
});


getCoupon needs to be elevated to work: elevate - Velo API Reference - Wix.com

Ok, permissions required. I think the docs on getCoupon() should at least show one example of how to structure the elevated call if that’s the only way it can be run.

My backend .jsw file now looks like this, but still returns everything as “undefined”.

import { coupons } from 'wix-marketing.v2';
import * as wixAuth from 'wix-auth';
import { elevate } from 'wix-auth';

const elevatedGetCoupon = wixAuth.elevate(coupons.getCoupon);

export async function getCoupon(id) {
  return elevatedGetCoupon(id)
    .then((result) => {
      return result;
    })
    .catch((error) => {
      console.log(error);
    });
}

any ideas why elevate getcoupon() isn’t working here? The Wix docs are very vague.