Prestan icon indicating copy to clipboard operation
Prestan copied to clipboard

JSON format not returned

Open jcerdan opened this issue 9 years ago • 3 comments

Hi,

Passing the param output_format='JSON' it should return a JSON output, but I get the following error: Requesting[get] http://www.xxxxxxxxxxxxxxx.com/api/products/?output_format=JSON with options {} { [Error: Non-whitespace before first tag. Line: 0 Column: 1 Char: {] cause: [Error: Non-whitespace before first tag. Line: 0 Column: 1 Char: {], isOperational: true }

jcerdan avatar Nov 10 '15 16:11 jcerdan

Can you post the code you're using?

xbenjii avatar Nov 10 '15 16:11 xbenjii

Here's the code:

var Prestan = require('./index.js');
prestan = new Prestan('http://www.xxxxxxxxxxx.com', 'XXXXXXXXXXXXXXXXXXX', {debug: true});
prestan.get('products',{output_format: 'JSON'}).then(function(response) {
    console.log(response);
}).catch(function(errors) {
    console.log(errors);
});

The output I get is the one from first comment. Going to the URL in the output shows de JSON object.

jcerdan avatar Nov 11 '15 08:11 jcerdan

You don't need {output_format: 'JSON'}, JSON is returned from the parser.

xbenjii avatar Nov 11 '15 16:11 xbenjii