Skip to content
Source
Sign inSign up
TanStack/bling

trying to fix POST method #8

OpenJLarky(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/8/headopened

Showing 2 changed files with 13 additions and 13 deletions.

x
0 of 2 viewed, 2 left
12 additions and 12 deletionspackages/bling/src/utils/utils.tsModified
View file
@@ -156,11 +156,15 @@
​
export function mergeRequestInits(...objs: (RequestInit | undefined)[]) {
- return Object.assign.call(null, [
- {},
- ...objs,
- { headers: mergeHeaders(...objs.map((o) => o && o.headers)) },
- ])
+ const out = {} as Record<keyof RequestInit, any>
+ for (const obj of objs) {
+ if (!obj) continue
+ for (const key in obj) {
+ out[key as keyof RequestInit] = obj[key as keyof RequestInit]
+ }
+ }
+ out.headers = mergeHeaders(...objs.map((o) => o && o.headers))
+ return out as RequestInit
​
export async function parseResponse(response: Response) {
@@ -204,13 +208,9 @@
​
export function mergeFetchOpts(...objs: (FetchFnCtxOptions | undefined)[]) {
- return Object.assign.call(null, [
- {},
- ...objs,
- {