Hello guys.
I have just started to learn meteor and javascript as well.
I wanted to make an app for my Particle.io photon project so i have a clear goal that makes this fun
However i have some issues, the particle requires a NPM package as you can see here
When i looking around on the forum it appears meteor will not be able to handle this as of 1.3, so when will 1.3 be released you think? I guess i can start with the beta but then i come to another issue, knowledge
Is there any tutorials out there that explain how to import NPM package in meteor, i cant seem to find any one, remember im new to this.
Have anyone used this particle-api.js and can share some how to or example code that they written in meteor, so i have something to study to understand how it works?
Is your app utilizing Particle.getEventStream()? The recent depreciation of sparkjs broke my app. I think I’m going to have to use Particle.getVariable() in conjunction with setTimeout() until I can get a (lot) better understanding of promises.
I im a total beginner im affraid so i have not been able to start with particle.api.js yet.
Still learning meteor and material design before i start with particle.
I guess i am the one that will ask you questions when i get there
Have you been able to get your code to work?
Is there a chance that you can share your code, the part where you are asking for particle events?
i found myself to be able to understand better if i actually see working code and follow the flow.
There are not so many examples out there for particle-api-js that can help a beginner
i found a meteor particle skeleton on github but that was for the old spark, i was able to get it to work
but the particle-api-js is very different.
Anyway, i will do my best to get this to work but if you have already managed ?
So, here’s my “playground” for trying to accomplish my goal of being able to call meteor methods from within particle-api-js getEventStream() using 1.2…
if (Meteor.isServer) {
var Particle = Meteor.npmRequire('particle-api-js');
var particle = new Particle();
var particleLogin = particle.login({
username: 'USERNAME',
password: 'PASSWORD'
});
particleLogin.then(function (data) {
return data.body.access_token;
}).then(function (token) {
console.log(token);
return particle.getEventStream({
deviceId: 'DEVICE_ID',
auth: token
});
}).then(function (stream) {
stream.on('event', function (data) {
var eventString = data.name + ": " + data.data;
console.log(eventString);
});
});
}
The console.log() works, but I get an error whenever I try to call a meteor method or insert into a mongo db.
I had a working example using spark, but it quit working in the past week - “An error occurred while getting core attrs: [Error: invalid_token]”
I have been on a google tour and have found some people that have made projects with particle-api-js.
Its not examples but completed project and since i am not a coder just a person with visions that needs a simple app
im affraid i dont understand everything with it.
Here are some links, maybe you can understand everything with it.
I will try to see if i can get something going on with this data
but i would like to ask if you can get it to work i need help with the following.
In the HTML file i want to have a login that log me in to the particle cloud, when im logged in i want
to receive all events in to my mongo database where is store them and show them on a event view.
I also want the eventview to collect new events and update the view if its happen while i look at it.
The most important for me is that when i get a new event i get a notification on my phone so i know that is has happened.
In the end this will be a mobile app that will only show events and notify me about it, i will not control anything with it.
When i have done all that i will also try to write a tutorial of it so new people like me don’t have to struggle so much.
i think with this as a starter me and others will be able to continue to work with all the other feature the api has.
What do you think, do we have a starter point here ?
I found a little time today and tested your example and some others.
I wonder if the issue you encounter is this the following
XMLHttpRequest cannot load https://api.particle.io/oauth/token. A wildcard ‘*’ cannot be used in the ‘Access-Control-Allow-Origin’ header when the credentials flag is true. Origin ‘http://localhost:3000’ is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.
If i check the consol of chrome i get that error.
Firefox also gives error but not so detailed.
Im at lost on how to fix it thou. I will ask the question on the particle.io community site and see what they say.