Is the promise rejected when a REST.post request fails?

I'm doing something like this and I'm wondering in which case the promise is rejected (when the body and all stuff is correct). Is the promise rejected when the HTTP status code is not 2xx ? Is there a Type I can use?
try {
await client.rest.post(Routes.channelMessages(postId), {
body: {
// ...
},
files: files
});
} catch (error) {
// ??
}
try {
await client.rest.post(Routes.channelMessages(postId), {
body: {
// ...
},
files: files
});
} catch (error) {
// ??
}
5 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
d.js docs
d.js docs2mo ago
:class: DiscordAPIError @2.4.0 Represents an API error returned by Discord
LukeZ
LukeZOP2mo ago
Is that the resolved or the rejected result?
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
LukeZ
LukeZOP2mo ago
ai, okay Ty all
Want results from more Discord servers?
Add your server