This is what I have. The backend function is receiving the data properly but it is not performing the query. I am not getting any error or object . I’ve tried get also but it does work on the frontend but not backend.
Frontend
import {email} from 'backend/email.jsw';
export function click(event) {
email(
$w("#input1").value)
.then(function() {
console.log("email was sent");
}
);
}
Backend
import wixData from 'wix-data';
export function email (data1) {
let userEmail = data1
console.log(userEmail); //Console log sucesfull
wixData.query("Profile")
.find()
.then( (results) => {
let firstItem = results.items[0]; console.log(firstItem);
} )
.catch( (err) => {
let errorMsg = err; console.log(errorMsg);
} );
}
What do you expect the function ‘email’ to do ?
It doesn’t use the user email in its query and doesn’t seem to be doing anything with the result of the query apart from printing the first item (given that the query was correct).
Please elaborate or provide a link to your site so I may assist you further.
Hi, I have a similar issue. I am writing backend code on my site. I want to get the count (actually other data but for now doing the count only).
I am writing this in https-functions.js
But it returns ERR_EMPTY_RESPONSE
import {ok, badRequest, notFound, serverError } from ‘wix-http-functions’;
import wixData from ‘wix-data’;