URLs use forward-slash, "/", and not back-slash , "\".
So, using your example:
http.get('/getmejson')
.subscribe((response) => {
console.log(response);
});
On Wed, Aug 23, 2017 at 4:32 PM LJ <[email protected]> wrote:
>
> Hi
>
> I have angular front end with basic button click it triggers http get to
> express backend. I have router on the backend which takes the request and
> redirects to external server and gets back json data.
> Now my backend part was working fine until I added angular front end to
> it.
>
> Ex,
> backend router takes request from browser for url "\getmejson" then
> http:\\localhost:3000\getmejson -> calls external server configured in
> backend itself for credentials, login etc + authenication headers and gets
> json.
> JSON fetched printed on console.
>
> Now, I added front end code in angular 4 with service in TS, and other
> code etc.
> Button click calls basic
> http.get('sameURLhere') .subscribe(data=> {console.log(data)});
>
> I know console.log will not work since it is async request and I see 404
> returned. Browser trace is not very useful for newbie like me and I learnt
> for basic json fetching I do not need fancy and basic subscribe should work
> without implementing Observable. I want this request to be forwarded to
> backend router then to external server and data back to front end so I can
> render it.
>
> Please suggest. I may not be able to give full codes but basic structure
> if needed.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Angular and AngularJS discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>
--
Lucas Lacroix
Computer Scientist
Advanced Technology Division, MEDITECH <http://ehr.meditech.com/>
781-774-2293
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.