2 years ago
#61799
Mikha Matta
React native can't send sms with Vonage Nexmo
I am trying to send sms via Vonage Nexmo, I get this error:
{"_bodyBlob": {"_data": {"__collector": [Object], "blobId": "03232404-7668-4E97-ADB3-CC7D084EF6B3", "name": "api.txt", "offset": 0, "size": 49, "type": "application/json"}}, "_bodyInit": {"_data": {"__collector": [Object], "blobId": "03232404-7668-4E97-ADB3-CC7D084EF6B3", "name": "api.txt", "offset": 0, "size": 49, "type": "application/json"}}, "bodyUsed": false, "headers": {"map": {"content-disposition": "attachment; filename="api.txt"", "content-length": "49", "content-type": "application/json", "date": "Mon, 17 Jan 2022 17:18:59 GMT", "server": "nginx", "strict-transport-security": "max-age=31536000; includeSubdomains", "x-content-type-options": "nosniff", "x-envoy-upstream-service-time": "1", "x-frame-options": "deny", "x-nexmo-trace-id": "57b091eb128ef3910815ecbbb0df9632", "x-xss-protection": "1; mode=block;"}}, "ok": false, "status": 401, "statusText": "", "type": "default", "url": "https://api.nexmo.com/v1/messages"}
this is my fetch code:
const sendSms = (phone,message) =>{
var url = ALL.NEXMO_URL;
var bearer = ALL.NEXMO_TOKEN;
fetch(url, {
method: 'POST',
headers: {
'Authorization': bearer,
'Content-Type': 'application/json'
},
body:{
"api_key":ALL.NEXMO_API_KEY,
"api_secret":ALL.NEXMO_API_SECRET,
"message_type": "text",
"text": message,
"to": "XXX"+phone+"",
"from": "XXXXXXXXXXXX",
"channel": "sms",
"client_ref":"Jelivery"
}
}).then(responseJson => {
console.log(responseJson);
})
.catch(error => {
console.log(error);
});
};
this is my consts define
export const NEXMO_URL = "https://api.nexmo.com/v1/messages";
export const NEXMO_TOKEN = "Basic ENCODED BASE 64==";
export const NEXMO_API_SECRET = "XXXXX";
export const NEXMO_API_KEY = "XXXXX";
also
I tried to install rpm install Nexmo ... react native can't recognize this module in node_modules.
any help please?
reactjs
react-native
sms
vonage
0 Answers
Your Answer