javascript - Totaljs Unirest -
i have problem totaljs framework , unirest module.
error: **typeerror: object function (count){var arr=[];var self=this;var length=self.length;for(var i=0;i=count)return arr}return arr} has no method 'tolowercase' typeerror: object function (count){var arr=[];var self=this;var length=self.length;for(var i=0;i=count)return arr}return arr} **has no method 'tolowercase'****
function view_homepage() { var self = this; var unirest = require('unirest'); unirest.post('http://httpbin.org/post') .headers({ 'accept': 'application/json' }) .send({ "parameter": 23, "foo": "bar" }) .end(function (response) { console.log(response.body); }); self.view('homepage'); }
but don't understand error because sails.js works fine.
thank you
you can use built-in function:
function view_homepage() { var self = this; utils.request('http://httpbin.org/post', ['post', 'json'], { parameter: 23, foo: 'bar' }, function(err, response, status, headers) { console.log(err, response); }); self.view('homepage'); }
documentation:
http://docs.totaljs.com/v1.7.x/en.html#api~frameworkutils~utils.request
Comments
Post a Comment