@Emil said in Which javascript version on SDK?:
old javascript version
Is it possible to have a javascript in this environment send an SMS to the smsburst API?
We have it working in other environments, but this one just doesnt seem to work.
const http = require('http');
const encodedAuth = Buffer.from('abcd123:Password123!').toString('base64');
const headers = {
"Authorization": "Basic " + encodedAuth
};
const message = encodeURIComponent("IVONNE: Testing from Flic SDK");
const to = encodeURIComponent("+16475551212");
const senderNumber = encodeURIComponent("18335551212");
const repliesToEmail = encodeURIComponent("email@example.com");
const url = "https://api.transmitsms.com/send-sms.json?message=" + message + "&to=" + to + "&from=" + senderNumber + "&replies_to_email=" + repliesToEmail;
function sendSmsViaTransmitSms() {
console.log("Starting request to SMS Burst API...");
http.makeRequest({
url: url,
method: 'POST',
headers: headers
}, function(error, result) {
if (error) {
console.error("An error occurred during the HTTP request:", error);
} else {
console.log("Received response from SMS Burst API");
console.log("Response status code:", result.statusCode);
console.log("Response headers:", result.headers);
if (typeof result.content !== 'undefined') {
console.log("Response body:", result.content);
} else {
console.log("Response body not available in this format");
}
}
});
}
sendSmsViaTransmitSms();
Error is:
TypeError: undefined not callable (property 'from' of [object Function])
at [anon] (duk_js_call.c:2917) internal
at [anon] (root/basicBurstSMSTest/main.js:1)
at require (init.js:131)
at [anon] (init.js:139) preventsyield
at runInit () native strict preventsyield
at handlePacket (pipe_communication.js:48)
at readCallback (pipe_communication.js:93) preventsyield