Hello, how can I use new Headres() in wix code? I am getting error like this:
Please help, thanks in advance.
Hi,
Unfortunately, Wix currently does not support site custom headers.
If there is something specific you wish to achieve let us know, maybe there is a workaround in the meantime.
Dear Aleks,
Thanks for your reply.
Here is what I am trying to do:
The new Headers() in the second line is being underlined with red line in the code panel.
Is there a way to achieve this in another way?
Thanks in advance!
import { fetch } from 'wix-fetch';
const headers = new Headers();
headers.append("Authorization", "Basic Z3JhbmRzdHVkeTpHcm5U3Q4OA==");
headers.append("Content-Type", "application/json");
const raw = JSON.stringify({
"messages": [{
"recipient": "37498664040",
"priority": "2",
"sms": {
"originator": "GrandStudy",
"content": {
"text": "Test"
}
},
"message-id": "201902280917"
}]
});
const requestOptions = {
method: 'POST',
headers: headers,
body: raw,
};
$w.onReady(function () {
fetch("https://sendsms.nikita.am/broker-api/send", requestOptions)
.catch(err => console.log(err));
})
Hi,
If I understood your code correctly, the reference here will help you achieve your goal.
Thanks Aleks, got it!