How to get data from Native HTTP Request


#1

Hey there, and sorry for this beginner question…
I am not able to get the data out of the response I get from the Native HTTP Request.

function() {
this.http.get(logInURL, {}, {})
    .then((data) => {
        console.log(data.data); 
    })
    .catch((error) => {
        console.log(error);
    });
  }

I get this in my console: {“UserId”:“29-ee-49-9a0a-e19fa159f”}

How can I just get the 29-ee-49-9a0a-e19fa159f and pass it to a variable?

Thanks in advance!


#2

If you’re a beginner, forget about the existence of Ionic-Native HTTP and simply use Angular’s HttpClient instead. It is much friendlier.


#3

I always get CORS Issues with Angular Http in combination with WKWebview. And I have no access to the server.
I have a working app with HttpClient and UIWebview, but memory consumption is too high I think.

If I try console.log(data.data.UserId) nothing happens in the console…so can anyone help me how to get the UserId?