episerver / content-delivery-js-sdk

Apache License 2.0
22 stars 14 forks source link

Issue 26 custom headers #27

Closed Shelco closed 2 years ago

Shelco commented 2 years ago

I wasn´t sure about what to return from getHeader so I used the Record<string, any> that ApiHeaders is based on instead of the actual ApiHeaders since these seemed to be meant for language and continuation.

I made getHeaders into a promise like getAccessToken. I guess that probably wouldn´t be necessary for most wanting to pass custom headers (cookies) along, but I thought it might as well be the same as getAccessToken. Since both are promises, I suppose they could be run in parallell but it seems unlikely that both getAccessToken and getHeaders would be used together so I simply ran them in serial.

In this implementation config.getHeaders is run after the headers parameter is iterated, so any headers present in both would be overwritten by config.getHeaders.

Closes #26

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

JohanPetersson commented 2 years ago

Thank you for your contribution! Will create a new release as well.