Add WaniKani
This commit is contained in:
parent
d2dfb621f4
commit
ea09afc2d9
8 changed files with 248 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
|||
import fetch from "node-fetch"
|
||||
|
||||
export async function api<T>(url: string): Promise<T> {
|
||||
return fetch(url)
|
||||
export async function api<T>(url: string, restful_token?: string): Promise<T> {
|
||||
return (restful_token ? fetch(url, {headers: {"Authorization": `Bearer ${restful_token}`}}) : fetch(url))
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
console.error(response.status, response.statusText)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue