Public Key Not Found

Good afternoon all,

I am attempting to create a function that will automatically create a membership through my external loyalty program (through Whisqr) for the current member/user on my site. I am receiving an error message stating the public key is not found.

Here is my backend code:

import {fetch} from 'wix-fetch';  
import {wixData} from 'wix-data';

export function postLoyalty() {
 let options ={
 "headers": {        
 "X-Public": "pk_live_ba43e74df464cbf521dd07ee20443ff754c3afc11adc16df2594facb2147cd76"
        }
  }
 const url = 'https://whisqr.com/api/v1.2/user/customer/';
 const key = '<pk_live_ba43e74df464cbf521dd07ee20443ff754c3afc11adc16df2594facb2147cd76>';
     console.log("Url: ");

 return fetch(url, {method: 'post'})
    .then(response => {
 return response.json();
    })
    .then((data) => {
      console.log(data);
 return data;
    });
}

Here is my page code:

import {postLoyalty} from 'backend/Loyalty.jsw';
import {wixData} from 'wix-data';
import wixLocation from "wix-location";
import {myFunction} from 'public/core.js';
import wixUsers from 'wix-users';

$w.onReady(function () {
 let publickey = 'pk_live_ba43e74df464cbf521dd07ee20443ff754c3afc11adc16df2594facb2147cd76';
    myFunction(publickey)
    .then( (response) => {
        console.log(response); //your base64 encoded string
    })});

export function page1_viewportEnter(event) {
 //Add your code for this event here: 
 let email = wixUsers.currentUser.getEmail();
postLoyalty(email)
        .then(LoyaltyInfo => {
            console.log(LoyaltyInfo)
            $w("#text1").text = LoyaltyInfo.Results.Value;
        })
}

Any and all feedback is greatly appreciated!

It is advisable to not paste up any API key that you have used, especially when you post in different places.
https://stackoverflow.com/questions/58399409/how-to-add-private-members-to-external-api

Plus, before you go to far down the road with this, have you actually checked with Whisqr that they are indeed actually able to be integrated with Wix.

They have their own API and mention it on their own website:
API - Whisqr provides your business with the means to integrate your Membership Program with your Mobile App, Website and POS System. Reward members for making purchases and other profitable behaviours and restrict access, to content, to members in good standing.

What does Whisqr’s own support documentation say about using their own API?

Also, when you import from the backend, you don’t add the js or jsw file names.

So change from…

import {postLoyalty} from 'backend/Loyalty.jsw';
import {wixData} from 'wix-data';
import wixLocation from "wix-location";
import {myFunction} from 'public/core.js';
import wixUsers from 'wix-users';

To this…

import {postLoyalty} from 'backend/Loyalty';
import {wixData} from 'wix-data';
import wixLocation from "wix-location";
import {myFunction} from 'public/core';
import wixUsers from 'wix-users';

Finally, if you are wanting to expose something like Wix Users API to an outside source, then you might be better suited using HTTP Functions.
wix-http-functions - Velo API Reference - Wix.com

Have a look at this tutorial here for an example.
https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-myapi-and-myapiclient