I’m working on a project that uses Meteor js to subscribe to Particle events and send commands to my Photon. With the migration from sparkjs to particle-api-js and its use of promises, I’ve found myself at a standstill.
I’ve reviewed a couple tutorials on Meteor and promises, but I can’t figure out how to apply it to the updated api. Any help would be greatly appreciated.
I am new aswell and struggling, i posted those link on meteor forum. If you are able to get à good example to work please post easy example for us or make à tutorial
Please IF you guys encounter the same, post in the Thread your code and issue. Remember to use chrome since ie and firefox shows an other error with bad explanation
My resolution was to use this code on the server side.
var Particle = require('particle-api-js');
var particle = new Particle();
particle.login({username: 'email@example.com', password: 'pass'}).then(
function(data){
console.log('API call completed on promise resolve: ', data.body.access_token);
},
function(err) {
console.log('API call completed on promise fail: ', err);
}
);
Are you using 1.3?, try by creating a new project in 1.3 and put the code in a js file under the server folder and test.
Thats whats eventually made it work for me. The load order is pretty important in meteor. Since im a beginner as well i cant really explain it for you, but as a start you can make and modify the example that meteor has on their site to fit your need.
You also need to import some stuff, the boilerplate is not needed but it helps make the app looks good with little effort.
and i used it to study what other people do with their code.
npm install particle-api-js
git copy materalize boilerplate (https://github.com/Differential/meteor-boilerplate/tree/materialize)
meteor add module
npm install -g meteor-npm // to make command "require" work