diff --git a/server/src/graphql/resolvers.js b/server/src/graphql/resolvers.js index 7351fd43a..c9d0f2211 100644 --- a/server/src/graphql/resolvers.js +++ b/server/src/graphql/resolvers.js @@ -497,7 +497,7 @@ const resolvers = { category, status, ) - if (category === 'pokemon') { + if (category === 'pokemon' && result.pokemon) { result.pokemon = result.pokemon.map((x) => ({ ...x, allForms: !x.form, @@ -506,13 +506,13 @@ const resolvers = { xl: x.min_weight !== 0, })) } - if (category === 'invasion') { + if (category === 'invasion' && result.invasion) { result.invasion = result.invasion.map((x) => ({ ...x, real_grunt_id: PoracleAPI.getRealGruntId(x, Event.invasions), })) } - if (category === 'raid') { + if (category === 'raid' && result.raid) { result.raid = result.raid.map((x) => ({ ...x, allMoves: x.move === 9000, @@ -656,7 +656,7 @@ const resolvers = { status, data, ) - if (category === 'pokemon') { + if (category === 'pokemon' && result.pokemon) { result.pokemon = result.pokemon.map((x) => ({ ...x, allForms: !x.form, @@ -665,13 +665,13 @@ const resolvers = { xl: x.min_weight !== 0, })) } - if (category === 'invasion') { + if (category === 'invasion' && result.invasion) { result.invasion = result.invasion.map((x) => ({ ...x, real_grunt_id: PoracleAPI.getRealGruntId(x, Event.invasions), })) } - if (category === 'raid') { + if (category === 'raid' && result.raid) { result.raid = result.raid.map((x) => ({ ...x, allMoves: x.move === 9000, diff --git a/server/src/services/api/fetchJson.js b/server/src/services/api/fetchJson.js index 5f7ed839c..dc18f02e9 100644 --- a/server/src/services/api/fetchJson.js +++ b/server/src/services/api/fetchJson.js @@ -2,7 +2,7 @@ const fs = require('fs') const { resolve } = require('path') -const { default: fetch } = require('node-fetch') +const { default: fetch, Response } = require('node-fetch') const config = require('@rm/config') const { log, HELPERS } = require('@rm/logger') @@ -31,6 +31,12 @@ async function fetchJson(url, options = undefined) { return response.json() } catch (e) { if (e instanceof Error) { + if ( + e.cause instanceof Response && + e.cause.status === 404 && + url.includes('/api/pokemon/id') + ) + return e.cause log.error(HELPERS.fetch, `Unable to fetch ${url}`, '\n', e) if (options) { fs.writeFileSync(