I have been trying to store the result of a POST request into a variable. I am coding in Zapier
let numero= input_data["numero"]
let data = {element: numero, elemento: "www.link.it" }
fetch("url", {
method: "POST",
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(data)
})
.then(function(res) {
return res.text();
})
.then(function(body) {
console.log(body);
var output = {rawHTML: body};
callback(null, output);
})
.catch(callback);
Pretty new to this
Not sure if this has much to do with Zapier. It is just orfdinary Javascript fetch api
But you could for example do something like this:
let responseBody;
fetch("url", {
method: "POST",
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(data)
})
.then(function(res) {
responseBody = await res.text();
})
.then(function(body) {
console.log(body);
var output = {rawHTML: body};
callback(null, output);
})
.catch(callback);