I should make a GET request with body (I know, it’s strange, but this is what I have to do).
Here below my script:
let inputConfig = input.config();
let deliveryNote = inputConfig.deliveryNote; // array
let courier = inputConfig.corriere; // array
let deliveryDate = inputConfig.dataRitiro; // array
let token = inputConfig.token; // string
let authToken = String("Bearer " + token);
var trackingHeaders = new Headers();
trackingHeaders.append("Authorization", authToken);
trackingHeaders.append("Content-Type","application/json");
var trackRaw = JSON.stringify({
"deliveryNote": "2501461270",
"courier": "DHL",
"deliveryDate": "2022-05-05"
});
var trackReqOption = {
method: 'GET',
headers: trackingHeaders,
body: trackRaw
}
await fetch("https://api.retelogisticastorage.it/api/externalServices/trackDelivery", trackReqOption)
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.log('error', error));
The first few variables, should be used in the actual request’s body (trackRaw
). In order to test, I set the body with static fields.
The token
variable comes from a previous script.
Since I know that sending a GET request with body is an anomaly, I am asking you: am I doing this right? Airtable allows this kind of request?
The problem is: I always get this response:
"error"
Error {name: "TypeError"}
name: "TypeError"