Hello ,
I have backend module back.jsw from which I call function in another backend JS file , but could not get response.
here is back.jsw file with :
import {createnewcustomer} from ‘backend/jscreatecust.js’;
export function createcust(firstname,secondname) {
createnewcustomer(firstname,secondname)
.then(promise => {
console.log(promise);
ICustomer=promise;
});
console.log(ICustomer);
And file jscreatecust.js
import {fetch} from ‘wix-fetch’;
export function createnewcustomer(firstname,secondname) {
return fetch(url, {headers: {“Content-Type”: “application/json”},
method: ‘post’,
body: body})
.then(response => response.json())
.then(json => json.ICustomer);
}
would you please explain me what is wrong ?
The code in jscreate.js - returns value when called from Front end function…
But when calling it from back.jsw - I do not see even the console.log(promise) output in the browser - why is that ?
Please help as I spent all day trying to make it work.
My goal is to get value from createnewcustomer function and assign it to ICustomer variable.
Thank you in advance !!