mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
Handling rating limit of Discord Webhook API
This commit is contained in:
parent
027ce90f89
commit
f2af8d706d
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue