Hi everyone, I would be really happy if someone understand what’s the problem here…
I get this error everytime that I call my function from Backend : Uncaught (in promise) TypeError: (0 , a.sending) is not a function
Here is the code :
FRONT END
import {sending} from 'backend/aModule';
//...
if (pricingPlans.length !== 0) {
membership = planName.toString()
price = $w('#text68').text
let A = $w("#text30").text
let B = $w("#input1").value
let C = $w("#input3").value
let D = $w("#input4").value
sending(A, membership, B, C, price, D)
})
.catch(error => {
console.log(error);
});
import wixUsers from 'wix-users';
import {sending} from 'backend/aModule';
//...
var membership;
var price;
export function button3_click(event) {
let user = wixUsers.currentUser
user.getPricingPlans()
.then( (pricingPlans) => {
let firstPlan = pricingPlans[0];
let planName = firstPlan.name;
if (pricingPlans.length !== 0) {
membership = planName.toString()
price = $w('#text68').text
let program = $w("#text30").text
let nom = $w("#input1").value
let email = $w("#input3").value
let phone = $w("#input4").value
sending(membership, price, program, nom, email, phone)
.then(response => console.log(response))
} else {
membership = "no membership"
price = $w('#text68').text
let program = $w("#text30").text
let nom = $w("#input1").value
let email = $w("#input3").value
let phone = $w("#input4").value
sending(membership, price, program, nom, email, phone)
.then(response => console.log(response))
}})
.catch(error => {
console.log(error);
membership = "no membership"
price = $w('#text68').text
let program = $w("#text30").text
let nom = $w("#input1").value
let email = $w("#input3").value
let phone = $w("#input4").value
sending(membership, price, program, nom, email, phone)
.then(response => console.log(response))
});
@jonatandor35 Thanks again Actually, on the first version, I added a .catch() function in order to run sending() with different values if no user is currently logged in.
With your version, I end up having the error Uncaught(in promise) no user is currently logged in . Is there any elegant way to code what I need without relying on .catch() ?
Thanks !
@loppe I don’t understand your code fro the catch. If the promise failed from any reason , you shouldn’t try to repeat sending it, because you’ll get an error or a rejection again.