Handling rating limit of Discord Webhook API

This commit is contained in:
neomaking 2019-10-20 22:14:42 +02:00
parent 027ce90f89
commit f2af8d706d

View file

@ -152,12 +152,15 @@ export class DiscordWebhook implements INodeType {
responseData = await this.helpers.request(options);
} catch (error) {
if (error.statusCode === 429) {
// Return API Rate Limit error
throw new Error(`You are rate limited, please retry in ${error.response.body.retry_after} ms.`);
// Waiting rating limit
setTimeout(async () => {
responseData = await this.helpers.request(options)
},
error.response.body.retry_after);
}else {
// If it's another error code then return the JSON response
throw error;
}
// If it's another error code then return the JSON response
throw error;
}
returnData.push(responseData as IDataObject);