Hi,
I was trying an API which have json payload to send. I’ve write the code and run in the postman and it’s returning accurate results. But as now I’m using the code in Wix but getting error (screenshot attached). I’ve faced this issue for the first time & this kind of error as well.
import { fetch } from 'wix-fetch';
export async function testAPI() {
const secApiUrl = 'https://{URL here}/Registration';
let bodyRequest = JSON.stringify({
"UserId": "******",
"MemberCode": "*****",
"Password": "*******",
"RegnType": "NEW",
"Param": "T0004|Par||Kuma|01|M|01/01/1970|01|SI|||||||||||||N||||AFEPK2130F||||||||P||||||||SB|11415||HDFC0000001|Y|||||||||||||||||||||FirstName LastName|01|ADD 1|ADD 2|ADD 3|MUMBAI|MA|400001|INDIA|22721233||||test4@test.com|P||||||||||||9999999999|||||||||||||||||||K||||||||||||N||P|||SE|SE|",
"Filler1": "",
"Filler2": ""
})
let requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
"Authorization": "Bearer ******"
},
body: bodyRequest,
}
try {
let response = await fetch(secApiUrl,requestOptions)
let finalResponse = await response.text();
return finalResponse;
} catch (error){
console.log(error);
console.log(error.message);
throw error;
}
}