K
K
Kostya Ostapuk2018-02-16 20:26:32
JavaScript
Kostya Ostapuk, 2018-02-16 20:26:32

Get parameter from url angular, redirect from Github?

1. I go through the authorization link via Github oauth
2. Then it redirects me to my application localhost:4200/?code=999999999999#/
3. Since I have an angular router configured, without knowing this route, it throws me back to localhost:4200/#/. It happens so fast that I can't get this 'code'.
4. Did the following but writes undefined:

import { ActivatedRoute, Params } from '@angular/router';

this.route.queryParams.subscribe(params => {
      this.githubCode = params['code'];
      localStorage.setItem('githubCode', this.githubCode);
    });

5. I tried to hang guard on the path in the router
ps please help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Epifanov, 2018-02-16
@kacheleff

you can add such a route
, it should work when the url does not match any of the routes (usually it is used to show 404)
in AnyComponent already read the get-parameter, as you did above
. In this case, there should not be a redirect

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question