Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit a6f5fbd

Browse files
committed
Use spread syntax
1 parent c78af67 commit a6f5fbd

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/fetch.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,25 @@ import { ubiAppId } from './auth';
55
const promiseTimeout = <T>(promise: Promise<T>, ms: number, reject = true) =>
66
Promise.race([promise, new Promise((res, rej) => setTimeout(() => reject ? rej : res, ms))]);
77

8-
export default <T>(url: string, params: Partial<RequestInit> = {}) =>
8+
export default <T>(url: string, options: Partial<RequestInit> = {}) =>
99
async (token?: string): Promise<T> => {
1010

11+
const { headers, ...optionsRest } = options;
12+
1113
const response = await nodeFetch(
1214
url,
13-
Object.assign(
14-
{},
15-
{
15+
{
16+
...{
1617
method: 'GET',
1718
headers: {
1819
'Content-Type': 'application/json; charset=UTF-8',
1920
'Ubi-AppId': ubiAppId,
20-
'Authorization': token
21+
...token && { 'Authorization': token },
22+
...headers && { ...headers }
2123
}
2224
},
23-
params || {}
24-
)
25+
...optionsRest && { ...optionsRest }
26+
}
2527
);
2628

2729
const handleResponse = async (res: Response) => {

0 commit comments

Comments
 (0)