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

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

Not getting response from HTTP Get Method

get source code for method with @property decorator python

Angular 6 Get response headers with httpclient issue

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

Angular 5: get method with params and observe response

Perform Http get method in Angular with no retries and wait until server sends the response?

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

Http get method using angular6

Get response of POST request in angular 6

Angular6 HttpInterceptor get response body

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

Laravel Guzzle returns blank response in Get() method

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

get response value from angular observable after POST method

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

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

How to read RAW JSON in Angular JS from HTTP get method, when response type is arraybuffer?

Why is this get request giving an _isScalar exception?

get response when i call the post method

Unable to get the response in POST method in Python

How to do redirect instead of response to Get method

angular6 - call a service in response callback of same service

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

How get source message from http-request (sink) response?

Get Response Headers from Angular HttpClient call Async method azure AI computer vision

Response to GET method is 404 “Cannot GET” error

Angular get http response

How to get named json response Flutter using http get method

TOP Ranking

HotTag

Archive