Git Product home page Git Product logo

Comments (7)

chenkie avatar chenkie commented on June 27, 2024 1

Can you try passing Http to the deps array?

...

import {Http} from 'angular2/http';

...

provide(AuthHttp, {
  useFactory: (http) => {
    return new AuthHttp(new AuthConfig(), http);
  },
  deps: [Http]
})

...

Let me know if that works :)

from angular2-jwt.

louisscruz avatar louisscruz commented on June 27, 2024

That does it!!! Thank you! Never would have thought of doing that.

It's been a month or so since I've started with Angular2-jws. Is there any mention of this approach in the docs?

from angular2-jwt.

chenkie avatar chenkie commented on June 27, 2024

This is from a recent change. I'll update the readme to reflect it. Thanks!

from angular2-jwt.

escardin avatar escardin commented on June 27, 2024

You should just be able to provide auth config and authhttp like this:

provide(AuthConfig, {useValue: new AuthConfig()}),AuthHttp

I believe when I pulled the injector out of the AuthHttp constructor I updated the example (though I used a factory and not a value).

from angular2-jwt.

rvetere avatar rvetere commented on June 27, 2024

provide(AuthConfig, {useValue: new AuthConfig()}),AuthHttp

This is still not working on my side, beta.8 - i still get an exception:

Cannot resolve all parameters for 'AuthConfig'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'AuthConfig' is decorated with Injectable.

Error: Cannot read property 'getOptional' of undefined

Even if i try to give him the local config param in my provide, the error won't go away. Are now actually Decorators missing in the current AuthConfig implementation?

Update:

I've just copied over the variant to bootstrap from the project page (angular2-jwt):

provide(AuthHttp, { useFactory: (http) => { return new AuthHttp(new AuthConfig({ headerName: 'YOUR_HEADER_NAME', headerPrefix: 'YOUR_HEADER_PREFIX', tokenName: 'YOUR_TOKEN_NAME', tokenGetter: 'YOUR_TOKEN_GETTER_FUNCTION', noJwtError: true }), http); }, deps: [Http] })

Now this variant is working, yay! :) I know, my strings i'm defining for all the values in my config object are total non-sense, i just wanted to make it running first.. but leaving them empty has taken me into another error again (can't remember which one right now)

from angular2-jwt.

escardin avatar escardin commented on June 27, 2024

It doesn't need to be decorated if you use it via useValue, because you are instantiating it directly.

Can you provide us with your entire bootstrap? Are you providing AuthConfig anywhere else?

You can look at this plunk as well for ideas: http://plnkr.co/edit/pKazgpkXLX9ZgV02YuVf?p=preview

from angular2-jwt.

rvetere avatar rvetere commented on June 27, 2024

Thx @escardin for your answer - we crossed each other, i've just made an update on my comment how i could fix it ;)

from angular2-jwt.

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.