javascript - using rsvp module of ember.js in pebble js -
i new pebble js app dev , want json of url. came across rsvp module error following code:
/** * welcome pebble.js! * * write app. */ var ui = require('ui'); var ajax = require('ajax'); var rsvp = require('rsvp'); var vector2 = require('vector2'); var username = 'lamiastella'; var url = 'http://www.last.fm/user/' + username; var card = new ui.card({ title:'last.fm stat', subtitle:'fetching...' }); card.show(); var getjson = function(url) { var promise = new rsvp.promise(function(resolve, reject){ var client = new xmlhttprequest(); client.open("get", url); client.onreadystatechange = handler; client.responsetype = "json"; client.setrequestheader("accept", "application/json"); client.send(); function handler() { if (this.readystate === this.done) { if (this.status === 200) { resolve(this.response); } else { reject(this); } } }; }); return promise; }; ajax({ url: url }, function(data){ // var headline = data.match(/(.*?)<\/h1>/)[1]; var title= data.match(/<h1>(.*?)<\/h1>/); card.subtitle(title); //card.subtitle(headline); });
the error :
[phone] pebble-app.js:?: javascript error: error: cannot find module 'rsvp' @ object.loader.require (loader.js:34:11) @ require (loader.js:41:48) @ object.loader (app.js:9:12) @ object.loader.require (loader.js:44:10) @ require (loader.js:41:48)
p.s.: if using rsvp not way go how can extract "top artist" or similar information?
i using rsvp in pebble.js app. here's how i'm requiring it:
var rsvp = require('./rsvp.js');
the problem doesn't work in emulator, due missing global
variable in environment.
Comments
Post a Comment