I have two website using the same code in http-functions but one can use fluently but another always return 404 even I use the exact same code in that function.
Here’s the one on site A.
'use strict';
import wixData from 'wix-data';
import { ok, response, notFound, serverError, created } from 'wix-http-functions';
export function post_customer(request) {
let options = {
"headers": {
"Content-Type": "application/json"
}
};
// get the request body
return request.body.json()
.then((body) => {
let customergeo = {
"customerid": body.customerid.toString(),
"customername": body.customername
}
return wixData.insert("cloudcafe", customergeo);
})
.then((results) => {
options.body = {
"inserted": results
};
return created(options);
})
// something went wrong
.catch((error) => {
options.body = {
"error": error
};
return serverError(options);
});
}
Always return 201
Here’s the one on site B.
‘use strict’;
import wixData from ‘wix-data’;
import { ok, response, notFound, serverError, created } from ‘wix-http-functions’;
export function post_customer(request) {
let options = {
“headers”: {
“Content-Type”: “application/json”
}
};
// get the request body
return request.body.json()
.then((body) => {
let customergeo = {
"customerid": body.customerid.toString(),
"customername": body.customername
}
return wixData.insert("cloudcafe", customergeo);
})
.then((results) => {
options.body = {
"inserted": results
};
return created(options);
})
// something went wrong
.catch((error) => {
options.body = {
"error": error
};
return serverError(options);
});
}
Always return 404
Anyone got the answer please help. Thanks for advance.