Hi all,
I am trying to remotely update a DB table created on a website.
This DB table should only have one entry so an update is required and not an Insert.
I have created a DB that looks like this:
and at the backend section I have created a file called http-functions.js containing the following:
‘use strict’;
import {ok, response, badRequest} from ‘wix-http-functions’;
import wixData from ‘wix-data’; // To use wixData functions we need to import this
export function post_tabledata(request) {
return request.body.json()
.then(body => {
let dataInsert = {
“Date”: body.Date,
“DiscountPercent”: body.DiscountPercent,
“DiscountDueDate”: body.DiscountDueDate,
“FullPrice”: body.FullPrice,
“DiscountedPrice”: body.DiscountedPrice,
“ButtonURL”: body.ButtonURL
};
return wixData.insert(‘ChallengeDates’, dataInsert)
.then(result => ok({body: JSON.stringify(result)}))
. catch (err => response({status: 501, body: err}));
}
);
}
$w(‘ChallengeDates’).onRowSelect( (event) => {
let rowData = event.rowData;
console.log(rowData);
//wixLocation.to(rowData.imageUrl);
});
Now I am trying to send a message using Integromat using this format:
when sending the JSON to the site I get a 500 error
When looking at the log I get this message:
tails"root": { “insertId”:“f10f4225-5aea-4d8f-bc34-b8519836b93b”“timestamp”:“2019-10-23T15:07:05.257Z”“labels”: { “siteUrl”:“https://www.beitlali.com/_functions/tabledata”“revision”:“2568"“namespace”:“Corvid”“tenantId”:“f55db345-61ca-481c-a65a-1b39e5dc29ec”“viewMode”:“Site” } “sourceLocation”: { “file”:“backend/http-functions.js”“line”:24"column”:3 } “operation”: { “id”:“1571843225.2086912017012469"“producer”:“backend” } “jsonPayload”: { “message”:”[“Error loading web module backend/http-functions.js: $w is not defined”]" } “severity”:“ERROR”“receiveTimestamp”:“2019-10-23T15:07:05.517Z” }
Can anyone please assist with figuring out what am I doing wrong?
Thanks so much!
Lior