Skip to content

Commit

Permalink
Merge pull request #165 from hemedani/main
Browse files Browse the repository at this point in the history
🩹 add setHeader fn for lesanApi
  • Loading branch information
hemedani authored May 29, 2024
2 parents cf945fe + ee16823 commit da500de
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/types/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ export const lesanApi = (
...settings,
};
const setHeaders = (headers: Record<string, any>) => {
setting.headers = {
...setting.headers,
...headers,
};
};
const getSetting = () => setting;
const send = async <
TService extends keyof ReqType,
TModel extends keyof ReqType[TService],
Expand All @@ -106,9 +115,9 @@ export const lesanApi = (
};
}, additionalHeaders?: Record<string, any>) => {
const req = await fetch(URL, {
...setting,
...getSetting(),
headers: {
...setting.headers,
...getSetting().headers,
...additionalHeaders,
},
body: JSON.stringify(body),
Expand All @@ -117,7 +126,7 @@ export const lesanApi = (
return await req.json();
};
return { send };
return { send, setHeaders };
};\n
`;

Expand Down

0 comments on commit da500de

Please sign in to comment.