Add option to provide 'RequestInit' to items that use fetch
This commit is contained in:
parent
9415547461
commit
0927a76085
1 changed files with 6 additions and 6 deletions
|
@ -6,17 +6,17 @@ export default {
|
|||
return new FontFace(fontFamily, href).load();
|
||||
},
|
||||
|
||||
script(item: Item): Promise<HTMLElement> {
|
||||
script(item: Item, options: RequestInit = {}): Promise<HTMLElement> {
|
||||
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<HTMLElement> {
|
||||
css(item: Item, options: RequestInit = {}): Promise<HTMLElement> {
|
||||
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<HTMLElement> {
|
||||
json(item: Item, options: RequestInit = {}): Promise<HTMLElement> {
|
||||
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 || {}))
|
||||
|
|
Loading…
Reference in a new issue