fetch: 共通headerが送られてなかった
This commit is contained in:
parent
77620c1699
commit
3a1ec763ea
@ -17,22 +17,22 @@ const joinParamsToPath = (path: string, params: QueryParams) =>
|
|||||||
const fetchWrapper = (path: string, options: RequestInit = {}) =>
|
const fetchWrapper = (path: string, options: RequestInit = {}) =>
|
||||||
fetch(path, {
|
fetch(path, {
|
||||||
credentials: 'same-origin',
|
credentials: 'same-origin',
|
||||||
headers: { ...headers, ...options.headers },
|
|
||||||
...options,
|
...options,
|
||||||
|
headers: { ...headers, ...options.headers },
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchWithJson = (path: string, body?: any, options: RequestInit = {}) =>
|
const fetchWithJson = (path: string, body?: any, options: RequestInit = {}) =>
|
||||||
fetchWrapper(path, {
|
fetchWrapper(path, {
|
||||||
|
...options,
|
||||||
body: body && JSON.stringify(body),
|
body: body && JSON.stringify(body),
|
||||||
headers: { 'Content-Type': 'application/json', ...options.headers },
|
headers: { 'Content-Type': 'application/json', ...options.headers },
|
||||||
...options,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchWithForm = (path: string, body?: any, options: RequestInit = {}) =>
|
const fetchWithForm = (path: string, body?: any, options: RequestInit = {}) =>
|
||||||
fetchWrapper(path, {
|
fetchWrapper(path, {
|
||||||
|
...options,
|
||||||
body: body && stringify(body),
|
body: body && stringify(body),
|
||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded', ...options.headers },
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded', ...options.headers },
|
||||||
...options,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fetchGet = (path: string, params: QueryParams = {}, options: RequestInit = {}) =>
|
export const fetchGet = (path: string, params: QueryParams = {}, options: RequestInit = {}) =>
|
||||||
|
Loading…
Reference in New Issue
Block a user