Retry XIVAPI requests once if they fail

This commit is contained in:
karashiiro 2021-05-31 11:03:21 -07:00
parent e54bffe7fb
commit 1e6aeda945
2 changed files with 13 additions and 5 deletions

View file

@ -290,7 +290,13 @@ class CardCreator {
* @returns {Promise<Buffer>} A promise representating the construction of the card's image data.
*/
async createCard(charaId, customImage) {
const response = await fetch(`https://xivapi.com/character/${charaId}?extended=1&data=FC,mimo`);
const characterInfoUrl = `https://xivapi.com/character/${charaId}?extended=1&data=FC,mimo`;
const response = await fetch(characterInfoUrl);
if (!response.ok) {
// Retry once if the request fails
response = await fetch(characterInfoUrl);
}
const data = await response.json();
const canvasSize = this.canvasSize;