Good afternoon all, I am trying to get some guidance with my code. All I receive are links to articles which doesn’t really help because I’ve read most articles and still can not figure out where I am going wrong.
My goal is to connect the Private Member Data to my External API. I have visited the myAPI & myClientAPI examples and they do not provide me with what I need.
Here is my backend code, I am getting a #parsing #error stating the colon after “X-Hash” is #unexpected:
import * as CryptoJS from 'public/crypto-js.js';
import {fetch} from 'wix-fetch';
import {wixData} from 'wix-data';
export function conversion(){
var secret = "Password";
var string2Sign = "Striking Pursuits Membership Activated!";
var hash = CryptoJS.HmacSHA256(string2Sign, secret);
var signature = CryptoJS.enc.Base64.stringify(hash);
}
const API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export function createMember (email, firstName, password) {
return fetch("https://whisqr.com/api/v1.2/user/customer" + API_KEY, {
headers:
'X-Hash': 'I AM UNABLE TO GENERATE THIS CODE SUCCESSFULLY',
'Content-Type': 'application/json'
method: 'post',
body: JSON.stringify({email, firstName, password})
}).then(function(response) {
if (response.status >= 200 && response.status < 300)
return response.text();
else
return Error(response.statusText);
});
}
Also, when attempting to call the function on my page, I get a failure message stating:
“status”: “failure”,
“message”: “security check failed. Content hash mismatch.”
This is my page code:
import {createMember} from 'backend/Loyalty';
export function sendButton_onClick(event) {
createMember( $w("#emailInput").value,
$w("#firstNameInput").value,
$w("#passwordInput").value
)
.then(function() {
console.log("email was sent");
}
);
}
Any help with this would be appreciated. If payment is required for assistance, please forward me the details.