Also apply basic linting to Netlify functions
This commit is contained in:
parent
3d38ba1768
commit
eb85319f73
11 changed files with 272 additions and 258 deletions
|
@ -1,12 +1,14 @@
|
|||
import fetch from "node-fetch"
|
||||
import fetch from "node-fetch";
|
||||
|
||||
export async function api<T>(url: string, restful_token?: string): Promise<T> {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
return (restful_token ? fetch(url, {headers: {"Authorization": `Bearer ${restful_token}`}}) : fetch(url))
|
||||
.then(response => {
|
||||
.then(async response => {
|
||||
if (!response.ok) {
|
||||
console.error(response.status, response.statusText)
|
||||
throw new Error("Request failed :(")
|
||||
console.error(response.status, response.statusText);
|
||||
throw new Error("Request failed :(");
|
||||
}
|
||||
return response.json() as Promise<T>
|
||||
})
|
||||
|
||||
return response.json() as Promise<T>;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue