Git Product home page Git Product logo

Comments (6)

doktordirk avatar doktordirk commented on June 10, 2024

not that it should make a difference, but i use headers.set instead of append

from fetch-client.

arnonuem avatar arnonuem commented on June 10, 2024

not that it should make a difference, but i use headers.set instead of append

When using fetch-client it is headers.append and when using http-client it is headers.add but the problem here is that it seems like modification to the headers object which are done in an interceptor are ignored somehow.
Also it is strange that when i log the headers object with JSON.stringify then i see {} but when i log headers.url i see a url. This behaviour for me is a bit mystical.
Nevertheless i have not managed it to manipulate the request headers within an interception of the request. I know that in Angular it is no problem to do so :(
I just want to add Authorization: 'Bearer rz87rzr8z3...' to my headers.

from fetch-client.

Alexander-Taran avatar Alexander-Taran commented on June 10, 2024

@arnonuem look here https://github.com/SpoonX/aurelia-authentication/blob/master/src/fetchClientConfig.js

from fetch-client.

arnonuem avatar arnonuem commented on June 10, 2024

@Alexander-Taran i already did and found no symmantic difference there.

from fetch-client.

davismj avatar davismj commented on June 10, 2024

Also it is strange that when i log the headers object with JSON.stringify then i see {} but when i log headers.url i see a url. This behaviour for me is a bit mystical.

This is just how the Request object works in Chrome and maybe other browsers. It functions as a Map. JSON.stringify(new Map(['foo','bar'])) yields {} as well. If you want to log it, use JSON.stringify(Array.from(a.headers)).

https://developer.mozilla.org/en-US/docs/Web/API/Headers

from fetch-client.

arnonuem avatar arnonuem commented on June 10, 2024

It seems that request.headers.set( 'Authorization', 'Bearer ' + token ); seems to work. So i am closing this for now. Many thanks to @doktordirk and @davismj

from fetch-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.