telerik - NativeScript HTTP:getJSON doesn't work -
i have used original helloworld app , change model helloworldmodel mainmodel.
then required "http" when run app , klik button "updateaction" writes console , sets message.
the http request doesn't anything.
code: (main-view-model.js)
var __extends = this.__extends || function(d, b) { (var p in b) if (b.hasownproperty(p)) d[p] = b[p]; function __() { this.constructor = d; } __.prototype = b.prototype; d.prototype = new __(); }; var observable = require("data/observable"); var http = require("http"); var mainmodel = (function(_super) { __extends(mainmodel, _super); function mainmodel() { _super.call(this); console.log("mainmodel called"); this.set("message", "last updated" + " 2015-07-22 00:00:00"); this.set("message2", "last updated" + " 2015-07-22 00:00:00"); } mainmodel.prototype.updateaction = function() { console.log("updateaction"); this.set("message2", "last updated" + " 2015-07-22 01:00:00"); http.getjson("https://httpbin.org/get").then(function(r) { this.set("message", "last updated \n" + r); console.log("success"); console.log(r); }, function(e) { // argument (e) error! console.log("fail"); console.log(e); this.set("message", "last updated \n" + e); }); }; return mainmodel; })(observable.observable); exports.mainmodel = mainmodel; exports.mainviewmodel = new mainmodel();
what doing wrong?
note: i'm testing on iphone 6 emulator
it seems using getstring works , gives same response.
still wierd getjson doesn't work.
a working example is:
http.getstring("https://httpbin.org/get").then(function (r) { console.log("success"); console.log(r); }, function (e) { console.log("fail"); console.log(e); });
Comments
Post a Comment