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 );
});
}
This always return 201
Here’s the one on siteB
‘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 );
});
}
And It always return 404
Anyone has some solutions please help. Thank you for advance.