Below is my current code for my backend and page, I am not sure what I am doing wrong but I have read through the forum and read several articles and still have no clue of where I went wrong. Any and all feedback would be greatly appreciated!
BACK END 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;
});
}
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;
})
}