Angular6 Get method response "_isScalar":false,"source"

Uahmed

I am trying to show the json data on the html page. The data on the server shows me json data but when i try to show it on page it gives me this data

{"_isScalar":false,"source":{"_isScalar":false,"source":{"_isScalar":false,"source":{"_isScalar":true,"value":{"url":"https://feeds.citibikenyc.com/stations/stations.json","body":null,"reportProgress":false,"withCredentials":false,"responseType":"json","method":"GET","headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"params":{"updates":null,"cloneFrom":null,"encoder":{},"map":null},"urlWithParams":"https://feeds.citibikenyc.com/stations/stations.json"},"scheduler":null},"operator":{"concurrent":1}},"operator":{}},"operator":{}}

my code for getting the data is

import { HttpClient} from '@angular/common/http';
import { Injectable } from '@angular/core';

@Injectable()
export class GetdataService {
posts : any;
readonly ROOT_URL ="https://feeds.citibikenyc.com/stations/stations.json";
constructor(private http: HttpClient ) { }

getPosts()
{

this.posts = this.http.get(this.ROOT_URL );

return JSON.stringify(this.posts);
}


}
vicbyte

this.http.get() doesn't return data but rather an observable, that you have to subscribe to:

getPosts() {
  this.http.get(this.ROOT_URL)
    .subscribe((data) => {
        //DO STUFF HERE
    });
}

Readmore

Secondly, while it shouldn't be needed to decode JSON after you fix the observable-stuff, you decode json with JSON.parse() not JSON.stringify. stringify converts the object into string (the exact opposite of what you wanted).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to get _value from `Observable {_isScalar: false, source: BehaviorSubject}`

RXJS in Angular 6 returns only { "_isScalar": false }

Angular 8 Observable Returns "_isScalar:false..."

Angular6 HttpInterceptor get response body

Http get method using angular6

Angular js:Not able to get the response for the rest method

Angular 5: get method with params and observe response

Type 'Subscription' is missing the following properties from type 'Observable<any>': _isScalar, source, operator, lift, and 6 more

OffsetDateTime yielding "No injection source found for a parameter of type public javax.ws.rs.core.response" in GET method

Why is this get request giving an _isScalar exception?

get response value from angular observable after POST method

How can I return true/false based on api response message in my angular authguard method?

angular6 - call a service in response callback of same service

Response to GET method is 404 “Cannot GET” error

Get response of POST request in angular 6

Angular 6 Get response headers with httpclient issue

Angular get http response

Angular6 typescript extension method Observable<T>

Angular6 HttpClient Post method not working although Postman is successful?

Angular6: reuploading same Image wont trigger upload method

call a method inside a ngFor in my html (angular6)

Use of getter method or class variable inside angular6 template?

Why get method is not returning a Response object in reqwest?

Not getting response from HTTP Get Method

How to do redirect instead of response to Get method

Laravel Guzzle returns blank response in Get() method

get response when i call the post method

Unable to get the response in POST method in Python

Angular : http.get() method in angular will not give updated response for second same request call for API

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive