const REQUEST_METHOD = "POST";
var scriptConfig = input.config();
var webhookUrl = scriptConfig.WEBHOOK_URL;
var requestConfig = {
"method" : REQUEST_METHOD,
}
if (REQUEST_METHOD == "POST") {
// Adds scriptConfig content as JSON body of request
requestConfig.body = JSON.stringify(scriptConfig);
requestConfig.headers = {
"Content-Type": "application/json"
};
fetch(
webhookUrl,
requestConfig
).then(function(response) {
output.set("status", 'ok')
})
} else if (REQUEST_METHOD == "GET") {
// Adds scriptConfig content as query params of request
const qs = Object.keys(scriptConfig)
.map(key => `${key}=${scriptConfig[key]}`)
.join('&');
// Appends queryString parameters to URL
webhookUrl += '?' + qs
fetch(
webhookUrl,
requestConfig
).then(function(response) {
output.set("status", 'ok')
})
} else {
}
The script is used to generate a webhook where I get all infos that I want.
But the script runs too fast so some formulas and stuff dont have the time to be executed.
So, I just want to add a timeout before it, like 30 seconds for exemple.
How could I do that?
Thanks in advance!
And happy new year (in advance too ahah)
