mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -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);
|
responseData = await this.helpers.request(options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.statusCode === 429) {
|
if (error.statusCode === 429) {
|
||||||
// Return API Rate Limit error
|
// Waiting rating limit
|
||||||
throw new Error(`You are rate limited, please retry in ${error.response.body.retry_after} ms.`);
|
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);
|
returnData.push(responseData as IDataObject);
|
||||||
|
|
Loading…
Reference in a new issue