I can call my endpoint (with hardcode variable) it's successful in requesting ( got a response ), but when I try to use a variable, params from the record. It's stuck on the CORS problem, but I am not sure why,
(both variables are the same, the difference is the one from the variable does not worked,
and one from hardcode is worked)
//if I used hardcode in data, it work fine.
const requestApi = async (params) => {
const myHeaders = new Headers();
myHeaders.append("api-key", "xxxxxxxxx");
myHeaders.append("Content-Type", "application/json");
try {
const requestOptions = {
method: "POST",
headers: myHeaders,
body: params,
// JSON.stringify({
// "pid": "xxxxxx",
// "firstName": "xxxxxx",
// "lastName": "xxxxxxx",
// "birthDay": "xxxxxx",
// "laser": "xxxxxx"
// }),
};
const response = await remoteFetchAsync("https://xxxxxxxx", requestOptions);
const result = await response.text();
console.log("Record updated successfully.");
} catch (error) {
console.error('Error:', error);
}}
let table = base.getTable("Juristic");
let selectedRecord = await input.recordAsync('Select a record to use', table);
const data = JSON.stringify({
"pid": selectedRecord?.getCellValue("authorized1_id_card"),
"firstName": selectedRecord?.getCellValue("authorized1_firstname"),
"lastName": selectedRecord?.getCellValue("authorized1_lastname"),
"birthday": selectedRecord?.getCellValue("authorized1_dob").replace(RegExp('-', 'g'),""),
"laser": selectedRecord?.getCellValue("authorized1_laser_id"),
})
await requestApi(data)