question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Logging in console always show null when user angular httpCliend

See original GitHub issue

I user HttpClient of angular9 to call mock mirage js but in console tab it always show null but actually I got response. this is my code.

Angular code

this.http.get('api/business-type').subscribe((res) => {
      console.log(res);
  });

Mirage js code

import * as businessType from './mockFile/BusnessType.json';

export function mockServer() {
  return new Server({
    routes() {
      this.passthrough();
      this.namespace = "api";
      this.get('/business-type', () => businessType.default); // JSON Object
    },
  })
};

console image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
zoltan-nzcommented, Apr 16, 2020

@Jesniphat You can see a Mirage.js with Angular 9 implementation here: https://github.com/zoltan-nz/hello-angular/tree/master/mirage

Hope it gives you a few ideas.

0reactions
ryantocommented, May 21, 2020

Oh, looks like we already have an issue for this one: https://github.com/miragejs/miragejs/issues/329

I’m going to close this issue and use #329 as the tracking issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HttpClient get return always null for any rest API - Stack Overflow
It always returns undefined (and not null), because your method doesn't return anything. Add return before this.http.get(... . And remove the ...
Read more >
NgModel - Angular
This directive is used by itself or as part of a larger form. Use the ngModel selector to activate it. It accepts a...
Read more >
FormControl - Angular
This argument always implicitly includes null because the control can be reset. To change this behavior, set nonNullable or see the usage notes...
Read more >
Router - Angular
How to handle a navigation request to the current URL. One of: 'ignore' : The router ignores the request. 'reload' : The router...
Read more >
Communicating with backend services using HTTP - Angular
The HttpClient service makes use of observables for all transactions. You must import the RxJS observable and operator symbols that appear in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found