This code is not working and need a fix asap as its stopping my live site from working.
http-functions.js
export function use_formapi(request) {
let options = {
"success": true,
"body": {
"code": "200",
"message": "File uploaded"
},
"headers": {
"Content-Type": "application/json"
}
};
return request.body.json()
.then( (body) => {
return addd(body)
})
.then( (results) => {
let item = results;
return created(options);
} )
.catch( (err) => {
let errorMsg = err;
return serverError(err);
} );
}
adddata.js
import {ok, notFound, created, serverError, response} from 'wix-http-functions';
import wixData from 'wix-data';
export function addd(body) {
let data = `Email: ${body.email}
Page: ${body.url}
Type: ${body.type}
Rating: ${body.starrating}
Message: ${body.realmessage}`
let theinsert = {
"message": data,
"title": "Form submission",
"key": body.key,
"type": body.type,
"starrating": body.starrating,
"screenshot": body.screenshot,
"url": body.url,
"email": body.email,
"realmessage": body.realmessage
}
return wixData.insert("dclicks", theinsert);
}
I have my import statements setup right and my code looks fine. why is function throwing error 500?
