Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Parse.com REST API with query in node.js - how to use data-encode from CURL
    primarykey
    data
    text
    <p>I am trying to replicate the example of the parse.com rest API below:</p> <pre><code>curl -X GET \ -H "X-Parse-Application-Id: APP_ID" \ -H "X-Parse-REST-API-Key: API_KEY" \ -G \ --data-urlencode 'where={"playerName":"John"}' \ https://api.parse.com/1/classes/GameScore </code></pre> <p>So, based on an example found on Stackoverflow, I implemented the function:</p> <pre><code>var https = require("https"); exports.getJSON = function(options, onResult){ var prot = options.port == 443 ? https : http; var req = prot.request(options, function(res){ var output = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { output += chunk; }); res.on('end', function() { var obj = JSON.parse(output); onResult(res.statusCode, obj); }); }); req.on('error', function(err) { }); req.end(); }; </code></pre> <p>which I call like that :</p> <pre><code>var options = { host: 'api.parse.com', port: 443, path: '/1/classes/GameScore', method: 'GET', headers: { 'X-Parse-Application-Id': 'APP_ID', 'X-Parse-REST-API-Key': 'APP_KEY' } }; rest.getJSON(options, function(statusCode, result) { // I could work with the result html/json here. I could also just return it //console.log("onResult: (" + statusCode + ")" + JSON.stringify(result)); res.statusCode = statusCode; res.send(result); }); </code></pre> <p>My question is, how do I send the "--data-urlencode 'where={"playerName":"Sean Plott","cheatMode":false}' bit? I tried appending it to the path by setting the path in the options like that: '/1/classes/GameScore?playerName=John, but that didn't work, I received all the GameScore, not the ones from John</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload