I’ve created a backend code to send a request to the server, and it seems like the data(object) doesn’t pass to our server. I am assuming that the body can be only be a string type after I read the documents. Is there a way that I can post a request with the object data
import {fetch} from ‘wix-fetch’;
export function postCurrentPayment(Email, FName, LName, Country, Phone, Amount, CardNumber, ExpDate, CVV, BFName, BLName)
{
let url = “http://www.eemmss.biz/api/donation”;
let username = ‘2’;
let password = ‘EEMSOdsJI2SdF13i4sd9fv3j’;
let headers = {
‘Authorization’: ‘Basic MjpFRU1TT2RzSkkyU2RGMTNpNHNkOWZ2M2o=’,
‘Content-Type’: ‘application/json’
};
let data = {
“Amount” : Amount,
“DonationType” : 140,
“PaymentType” : 153,
“Category” : 159,
“FirstName” : FName,
“LastName” : LName,
“Country” : Country,
“Phone” : Phone,
“CardNumber” : CardNumber,
“ExpDate” : ExpDate,
“CVV” : CVV,
“BFName” : BFName,
“BLName” : BLName,
“Language” : “E”,
“TransactionDate” : 1,
“Newsletter” : 0,
“CTitle”: 0
}
console.log( typeof (data));
let options = {
method :‘POST’,
headers: headers,
body: data
}
return fetch(url, options)
.then((httpResponse) => {
console.log(httpResponse)
// Add code to check the response
});
}