Because I work currently with an API returning JSON code I would need to get the whole JSON code returned by API and insert this code line by line (well formatted, if possible in an easy way) into a <pre> element.
My code I use at the moment:
$.getJSON(url + "api/get", function( data ) {
$.each(data, function(i, field){
$("#result").append(field);
console.log(field);
});
});
Using the console output I get:
Object {message: "api key invalid"}
This seems to be strange, because when using postman to debug I get:
{"errors":{"message":"api key invalid"}}
How to get the response postman gets and how to insert this into my pre element, because at the moment this doesn't work too.
$.get()the content as raw text?console.log(data)to see how the object looks then access the properties as needed. This might help ► stackoverflow.com/questions/10709241/…<pre>textbox, to show my users the whole reply from the API.$("#result").append(JSON.stringify(data, null, 2));