chore(eslint): fix getJSON reponse type
This commit is contained in:
parent
beafa21796
commit
a914950982
1 changed files with 10 additions and 3 deletions
|
@ -88,6 +88,15 @@ export function ajax(options: Rails.AjaxOptions) {
|
|||
});
|
||||
}
|
||||
|
||||
class ResponseError extends Error {
|
||||
response: Response;
|
||||
|
||||
constructor(response: Response) {
|
||||
super(String(response.statusText || response.status));
|
||||
this.response = response;
|
||||
}
|
||||
}
|
||||
|
||||
export function getJSON(url: string, data: unknown, method = 'GET') {
|
||||
const { query, ...options } = fetchOptions(data, method);
|
||||
|
||||
|
@ -98,9 +107,7 @@ export function getJSON(url: string, data: unknown, method = 'GET') {
|
|||
}
|
||||
return response.json();
|
||||
}
|
||||
const error = new Error(String(response.statusText || response.status));
|
||||
(error as any).response = response;
|
||||
throw error;
|
||||
throw new ResponseError(response);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue