Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>"is it possible to cancel a request?"</p> </blockquote> <p><code>HTTP.call()</code> does not appear to return an object on which we could call something like a <code>stop()</code> method. Perhaps a solution would be to prevent execution of your callback based on a <code>Session</code> variable?</p> <pre class="lang-js prettyprint-override"><code>HTTP.call("GET", url, function(error, result) { if (!Session.get("stopHTTP")) { // Callback code here } }); </code></pre> <p>Then when you reach a point where you want to cancel the request, do this:</p> <pre class="lang-js prettyprint-override"><code>Session.set("stopHTTP", true); </code></pre> <p>On the server, instead of <code>Session</code> perhaps you could use an <a href="https://www.eventedmind.com/feed/49CkbYeyKoa7MyH5R" rel="nofollow">environment variable</a>?</p> <p>Note that the <code>HTTP.call()</code> options object does accept a <code>timeout</code> key, so if you're just worried about the request never timing out, you can set this to whatever millisecond integer you want.</p> <blockquote> <p>"is it possible to have multiple query parameters which share the same key?"</p> </blockquote> <p>Yes, this appears to be possible. Here's a simple test I used:</p> <p>Meteor code:</p> <pre class="lang-js prettyprint-override"><code>HTTP.call("GET", "http://localhost:1337", { query: "id=foo&amp;id=bar" }, function(error, result) { // ... }); </code></pre> <p>Separate Node.js server: (just the basic example on the Node.js homepage, with a <code>console.log</code> line to output the request URL with query string)</p> <pre class="lang-js prettyprint-override"><code>var http = require('http'); http.createServer(function(req, res) { console.log(req.url); // Here I log the request URL, with the query string res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello World\n'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/'); </code></pre> <p>When the Meteor server is run, the Node.js server logged:</p> <pre><code>/?id=foo&amp;id=bar </code></pre> <p>Of course, this is only for GET URL query parameters. If you need to do this for POST params, perhaps you could store the separate values as a serialized array string with <code>EJSON.stringify</code>?</p>
    singulars
    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.
    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