Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 65a483b4bc
Fetching contributors…

Cannot retrieve contributors at this time

21 lines (19 sloc) 0.799 kb
<section name="nodejs" class="nodejs">
<p class="ioDesc">In</p>
<pre class="incoming brush:js">
var request = require("request");
<% if @method is "GET" and not @headers: %>
request("<%= @apiUrl %><%= @url %>", function (error, response, body) {
<% else : %>
request({
url: "<%= @apiUrl %><%= @url %>",<% if @body: %>
body: <%= @helpers.escape @body.join('') %>,<% end %><% if @helpers.isNotEmpty @headers: %>
headers: {<%= ("#{@helpers.escape header}: #{@helpers.escape value}" for header,value of @headers).join(", ") %>}, <% end %>
method: "<%= @method.toUpperCase() %>"
}, function (error, response, body) {
<% end %>
console.log("Status", response.statusCode);
console.log("Headers", JSON.stringify(response.headers));
console.log("Reponse received", body);
});
</section>
Jump to Line
Something went wrong with that request. Please try again.