(
url: string,
options: RequestInit = {},
)
| 84 | }; |
| 85 | |
| 86 | export function fetchApi( |
| 87 | url: string, |
| 88 | options: RequestInit = {}, |
| 89 | ): Promise<Response> { |
| 90 | if (options.method && options.method !== "GET") { |
| 91 | options.headers = options.headers || {}; |
| 92 | options.headers["X-XSRFToken"] = xsrf(); |
| 93 | } |
| 94 | if (url.startsWith("/")) { |
| 95 | url = "." + url; |
| 96 | } |
| 97 | |
| 98 | return fetch(url, { |
| 99 | credentials: "same-origin", |
| 100 | ...options, |
| 101 | }); |
| 102 | } |
| 103 | |
| 104 | fetchApi.put = (url: string, json: any, options: RequestInit = {}) => |
| 105 | fetchApi(url, { |
no test coverage detected
searching dependent graphs…