Here is my code:
function GETdynamoDBapi(phoneNumber) {
return new Promise(function (resolve, reject) {
fetch(
'https://api?phoneNumber=' +
phoneNumber
)
.then((res) => {
return res.json();
})
.then((res) => {
resolve(data);
})
.catch((err) => {
reject(err);
});
});
}
I have tried following two case of with and without +. I have both '4100000000' and '+4100000000' data on my database table. Phone Number is defined as string in database.
let response = await GETdynamoDBapi('+4100000000'); //error return data
let response = await GETdynamoDBapi('4100000000'); //return date success
How can I handle the '+' sign? Thanks!
(edited)
I also tried to test the API https://api?phoneNumber=+4100000000 on Insomnia and it works well. But when I try following in my code, it cannot return any data.
fetch(
'https://api?phoneNumber=+4100000000'
)