mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-08-20 09:34:35 -05:00
Always check response status codes
This commit is contained in:
16
src/api/f.ts
16
src/api/f.ts
@@ -42,6 +42,10 @@ export async function getLoginHash(token: string, timestamp: string | number, us
|
||||
signal,
|
||||
}).finally(cancel);
|
||||
|
||||
if (response.status !== 200) {
|
||||
throw new ErrorResponse('[s2s] Non-200 status code', response, await response.text());
|
||||
}
|
||||
|
||||
const data = await response.json() as LoginHashApiResponse | LoginHashApiError;
|
||||
|
||||
if ('error' in data) {
|
||||
@@ -87,6 +91,10 @@ export async function flapg(
|
||||
signal,
|
||||
}).finally(cancel);
|
||||
|
||||
if (response.status !== 200) {
|
||||
throw new ErrorResponse('[flapg] Non-200 status code', response, await response.text());
|
||||
}
|
||||
|
||||
const data = await response.json() as FlapgApiResponse;
|
||||
|
||||
debugFlapg('Got f parameter "%s"', data.result.f);
|
||||
@@ -160,6 +168,10 @@ export async function iminkf(
|
||||
signal,
|
||||
}).finally(cancel);
|
||||
|
||||
if (response.status !== 200) {
|
||||
throw new ErrorResponse('[imink] Non-200 status code', response, await response.text());
|
||||
}
|
||||
|
||||
const data = await response.json() as IminkFResponse | IminkFError;
|
||||
|
||||
if ('error' in data) {
|
||||
@@ -228,6 +240,10 @@ export async function genf(
|
||||
signal,
|
||||
}).finally(cancel);
|
||||
|
||||
if (response.status !== 200) {
|
||||
throw new ErrorResponse('[znca-api] Non-200 status code', response, await response.text());
|
||||
}
|
||||
|
||||
const data = await response.json() as AndroidZncaFResponse | AndroidZncaFError;
|
||||
|
||||
if ('error' in data) {
|
||||
|
||||
Reference in New Issue
Block a user