mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-03-21 18:04:10 -05:00
Update SplatNet 3 types, log GraphQL query ID for debugging
This commit is contained in:
parent
41623b1bb3
commit
56a991b03b
|
|
@ -2,7 +2,7 @@
|
|||
export interface BulletToken {
|
||||
bulletToken: string;
|
||||
lang: string;
|
||||
is_noe_country: 'true' | unknown;
|
||||
is_noe_country: 'true' | 'false';
|
||||
}
|
||||
|
||||
/** /graphql */
|
||||
|
|
|
|||
|
|
@ -29,7 +29,10 @@ export default class SplatNet3Api {
|
|||
public useragent: string,
|
||||
) {}
|
||||
|
||||
async fetch<T = unknown>(url: string, method = 'GET', body?: string | FormData, headers?: object) {
|
||||
async fetch<T = unknown>(
|
||||
url: string, method = 'GET', body?: string | FormData, headers?: object,
|
||||
/** @internal */ _log?: string
|
||||
) {
|
||||
const [signal, cancel] = timeoutSignal();
|
||||
const response = await fetch(SPLATNET3_URL + url, {
|
||||
method,
|
||||
|
|
@ -47,7 +50,7 @@ export default class SplatNet3Api {
|
|||
signal,
|
||||
}).finally(cancel);
|
||||
|
||||
debug('fetch %s %s, response %s', method, url, response.status);
|
||||
debug('fetch %s %s%s, response %s', method, url, _log ? ', ' + _log : '', response.status);
|
||||
|
||||
if (response.status !== 200) {
|
||||
throw new ErrorResponse('[splatnet3] Non-200 status code', response, await response.text());
|
||||
|
|
@ -69,7 +72,8 @@ export default class SplatNet3Api {
|
|||
},
|
||||
};
|
||||
|
||||
const data = await this.fetch<GraphQLResponse<T>>('/graphql', 'POST', JSON.stringify(req));
|
||||
const data = await this.fetch<GraphQLResponse<T>>('/graphql', 'POST', JSON.stringify(req), undefined,
|
||||
'graphql query ' + id);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user