From 0927a7608594ba90f85afc9efe8768b14a0bc889 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sun, 8 Oct 2023 06:03:31 -0300 Subject: [PATCH] Add option to provide 'RequestInit' to items that use fetch --- packages/typescript/postman/src/postman/request.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/typescript/postman/src/postman/request.ts b/packages/typescript/postman/src/postman/request.ts index 455f654..7937ad3 100644 --- a/packages/typescript/postman/src/postman/request.ts +++ b/packages/typescript/postman/src/postman/request.ts @@ -6,17 +6,17 @@ export default { return new FontFace(fontFamily, href).load(); }, - script(item: Item): Promise { + script(item: Item, options: RequestInit = {}): Promise { const { href } = item; - return fetch(href) + return fetch(href, options) .then((res) => res.text()) .then((text) => ({ type: 'application/javascript', text })) .then((props) => Object.assign(document.createElement('script'), props)); }, - css(item: Item): Promise { + css(item: Item, options: RequestInit = {}): Promise { const { href } = item; - return fetch(href) + return fetch(href, options) .then((res) => res.text()) .then((text) => ({ innerText: text })) .then((props) => Object.assign(document.createElement('style'), props)); @@ -32,9 +32,9 @@ export default { }); }, - json(item: Item): Promise { + json(item: Item, options: RequestInit = {}): Promise { const { href } = item; - return fetch(href) + return fetch(href, options) .then((res) => res.text()) .then((text) => ({type: 'application/json', text})) .then((props) => Object.assign(props, item.props || {}))