Skip to content

Commit

Permalink
fix: support object based headers
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Aug 27, 2024
1 parent 578f2c5 commit 1125f5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion playground/vanilla/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import './style.css'

const headers = new Headers()
headers.append('Awiwi', 'Awiwi')

const headers2 = {
'Awiwi': 'Awiwi'
}
console.log(headers2.constructor.name)
// 2. Initialize the client with the preview token
// from your space dashboard at https://app.storyblok.com
const Storyblok = new StoryblokClient({
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Storyblok {
headers.set('Accept', 'application/json')

if (config.headers) {
const entries = config.headers.entries().toArray()
const entries = (config.headers.constructor.name === 'Headers') ? config.headers.entries().toArray() : Object.entries(config.headers)

entries.forEach(([key, value]: [string, string]) => {
headers.set(key, value)
Expand Down

0 comments on commit 1125f5f

Please sign in to comment.