top of page

Forum Posts

andrew
Jul 11, 2021
In Forum Discussions
Hi, I have implimented a node.js server and am sending a put() request to my wix backend code. The wix site receives the request fine and deals with the data exactly how i want. The issue is that my node.js server is receiving a response with status 500 from my wix site before any return is reached. If i put the 'return ok(options)' directly after the function definition, the node.js server receives the 200 status. Does anyone know why the wix server is responding with code 500 before it reaches any return command. import {ok, serverError} from 'wix-http-functions'; import wixData from 'wix-data'; export function put_myFunction(request) { console.log("received put request") let options = { "headers": { "Content-Type": "application/json" }, }; // get the request body request.body.json() .then( (body) => { console.log(body["deviceId"]) wixData.query("Devices") .eq("deviceId", body["deviceId"]) .find({"suppressAuth": true}) .then( (results) => { console.log(results) if(results.length > 0){ wixData.update("Devices", results.items[0],{"suppressAuth": true}) .then(() =>{ console.log("dataset updated"); options.body = { "inserted": results }; return ok(options); }) .catch( (err) => { let errorMsg = err; console.log("error updating"); // return serverError(options); } ); }else{ // console.log("no device matching packet found") // return serverError(options); } }) //something went wrong .catch( (err) => { console.log("error finding device") options.body = { "error": err }; // return serverError(options); } ); }); }
0
1
8
andrew
Jul 04, 2021
In Forum Discussions
Hi all, Im trying to create a backend script that subscribes to an mqtt broker to receive packets from a device i have. Im attempting to use the npm package mqtt, but im having alot of difficulty getting it to do anything. can someone assist in what i should be doing?
0
1
21
A

andrew

More actions
bottom of page