HTTP Request
POST request with headers
var HTTP = require("lib/http"); var credential = { "email": document.getElementById("txt_email").value, "password": document.getElementById("txt_password").value }; HTTP.create() .setContentType("application/json") .setRequestBody(credential) .post(apiUrl + "myproject/auth/authenticate", function(res) { if ("error" in res) { console.error(res.error.message); } else if ("data" in res) { console.log(res.name); } }) ;
GET request with headers
var HTTP = require("lib/http"); HTTP.create() .setContentType("application/x-www-form-urlencoded") .setBearerAuth(token) .setUseCache(false) .get(apiUrl + "myproject/items/mycollection", function(res) { if ("error" in res) { console.error(res.error.message); } else if ("data" in res) { console.log(res.name); } }) ;