Giter Club home page Giter Club logo

Comments (18)

chenkie avatar chenkie commented on May 22, 2024

What error are you getting when doing get requests? Does the same error happen with other request types? I haven't seen any issues with beta 1. I'll have the Auth0 samples updated pretty soon.

Thanks!

from angular2-jwt.

tobika avatar tobika commented on May 22, 2024

Error: EXCEPTION: Error during evaluation of "click" ORIGINAL EXCEPTION: TypeError: First argument must be a url string or Request instance. ORIGINAL STACKTRACE: makeTypeError@http://127.0.0.1:3000/vendor.bundle.js:3338:13 Http</Http.prototype.request@http://127.0.0.1:3000/vendor.bundle.js:34297:1 AuthHttp</AuthHttp.prototype._request@http://127.0.0.1:3000/vendor.bundle.js:35666:24 AuthHttp</AuthHttp.prototype.requestHelper@http://127.0.0.1:3000/vendor.bundle.js:35678:17 AuthHttp</AuthHttp.prototype.get@http://127.0.0.1:3000/vendor.bundle.js:35682:17 [372]/App</App.prototype.getThing@http://127.0.0.1:3000/main.bundle.js:72:10 anonymous/ChangeDetector_App_3.prototype.handleEventInternal@viewFactory_App:361:23 AbstractChangeDetector</AbstractChangeDetector.prototype.handleEvent@http://127.0.0.1:3000/vendor.bundle.js:10910:25

As I said, when I look at the request instance in the browser it looks fine to my eyes. (Login worked fine with auth0)

This is how I start the request :
this.authHttp.get(URL) .subscribe( data => console.log(data), err => console.log(err), () => console.log('Complete') );

Thanks for your fast response. Will continue to look into it tomorrow.

from angular2-jwt.

tobika avatar tobika commented on May 22, 2024

If I replace the else if instance of with true the request works just fine. So the problem is that my request is not an instance of static_request_1.Request.

Http.prototype.request = function (url, options) {
        var responseObservable;
        if (lang_1.isString(url)) {
            responseObservable = httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions, options, enums_1.RequestMethod.Get, url)));
        }
        else if (url instanceof static_request_1.Request) {
            responseObservable = httpRequest(this._backend, url);
        }
        else {
            throw exceptions_1.makeTypeError('First argument must be a url string or Request instance.');
        }
        return responseObservable;
    };

Update:
Just also rebuild angular2-jwt with the last beta.1. Still same error, I start to think that it's just something with my project somewhere.
As a workaround I use a normal http.get and add the header with token myself.

from angular2-jwt.

feliksg avatar feliksg commented on May 22, 2024

I'm having the same issue when I pass in a string url to this.authHttp.get().

I don't think it's a problem with our apps (mine is nearly empty as i'm just starting this project), but rather a possible breaking change from https://github.com/angular/angular/blob/master/CHANGELOG.md#200-alpha48-2015-12-05.

from angular2-jwt.

escardin avatar escardin commented on May 22, 2024

@feliksg it is unlikely to be an issue with a breaking change from alpha48, as the library was updated specifically to deal with the breaking changes in the later alphas. Can you supply some sample code or a plunker that demonstrates the issue?

@tobika can you also provide sample code?

from angular2-jwt.

feliksg avatar feliksg commented on May 22, 2024

@escardin Sure, I created a plunkr with the code that i'm getting the error for, but not sure how to get the angular2-jwt dependency in plunkr.

https://plnkr.co/edit/d3ikfiiVDErzpKhBdx9p

from angular2-jwt.

chenkie avatar chenkie commented on May 22, 2024

Question for everyone seeing this error: what is your build setup? Are you working from a seed project?

I think this issue is being caused by some other dependencies and isn't specific to angular2-jwt. I'm currently working on updating the Auth0 samples that use angular2-jwt and I just now saw this error in an older version of the Webpack sample when using beta.1. The Webpack sample is based on angular2-webpack-starter. However, the SystemJS version which is based on ng2-play has no issues.

I'll comb through the deps in the Webpack version to try to find what it is.

from angular2-jwt.

feliksg avatar feliksg commented on May 22, 2024

I'm working from the angular2-webpack-starter (https://github.com/AngularClass/angular2-webpack-starter).

Thanks for responding so quickly and working with us to figure out the issue -- really appreciate it!

from angular2-jwt.

tobika avatar tobika commented on May 22, 2024

Same here, the angular-webpack-starter. Thanks a lot.

from angular2-jwt.

escardin avatar escardin commented on May 22, 2024

Here's a working plunk with get demonstrated. https://plnkr.co/edit/TPFeBZ45fwIWwvgPYrmn?p=preview

I based it on what @feliksg provided.

from angular2-jwt.

chenkie avatar chenkie commented on May 22, 2024

It looks like the issue for Webpack users might be the mixing of beta.0 and beta.1. @feliksg and @tobika can you please delete angular2-jwt from your node modules and try installing it by itself again with npm install angular2-jwt? Let me know if you still get the error after that. Thanks!

from angular2-jwt.

chenkie avatar chenkie commented on May 22, 2024

A quick note: the current version on npm still has beta.0 as the dep, but I want to see what happens with a clean install of where it's at first.

from angular2-jwt.

feliksg avatar feliksg commented on May 22, 2024

@chenkie I can confirm that i'm still having the issue after removing and installing it by itself. When installing it, it does list beta.0 as a dependency.

from angular2-jwt.

tobika avatar tobika commented on May 22, 2024

@chenkie same like @feliksg

from angular2-jwt.

chenkie avatar chenkie commented on May 22, 2024

Ok thanks. Can you try doing npm run clean? Depending on which version of the Webpack starter you're on, this might look different in the scripts in your package.json.

Also, can you check if there's a node_modules folder within the angular2-jwt directory? If so, can you let me know what happens if you delete that?

from angular2-jwt.

feliksg avatar feliksg commented on May 22, 2024

@chenkie That worked! I ran npm run clean then npm install and then removed the node_modules folder from the angular2-jwt directory.

Thank you so much for all of your help!

from angular2-jwt.

tobika avatar tobika commented on May 22, 2024

Thanks also from my side, followed your tips and it works now :)

from angular2-jwt.

chenkie avatar chenkie commented on May 22, 2024

Awesome good to hear :) I'm going to leave this issue open for now in case it pops up again before the next release.

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.