But when i try it chrome console returns this error
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.
I have been googling around about this error and what i can find is that
"this is a part of security, you cannot do that. If you want to allow credentials then your Access-Control-Allow-Origin must not use *. You will have to specify the exact domain."
But as a beginner i just cant find where i need to do this.
I also can see on this forum that several people have this issues so not sure if this is something that has started because of an update?
Can someone please explain where i need to specify the domain or/else remove the wildcard for a beginner?
var Particle = require('particle-api-js');
var particle = new Particle();
var access_token = "";
//get access token
particle.login({username: 'email', password: 'password'})
.then(
function(data){
access_token = data.body.access_token;
},
function(err) {
console.log('API call completed on promise fail: ', err);
}
);
var pumpStuff = function(message){
var fnPr = particle.callFunction({
deviceId: 'jackdaniels',
name: 'leanMachine',
argument: message,
auth: access_token
});
fnPr.then(
function(data) {u
console.log('Function called succesfully:', data);
}, function(err) {
console.log('An error occurred:', err);
}
);
};
exports.pumpStuff = pumpStuff;
But i cant pass the login part.
I use Meteor as framework but there is nothing in the HTML part and the app seems to work fine except that in the backgound chrome shows the error message.
I have been struggling some more about this today and read some threads on various places.
I could see that the particle-api-js was updated on version 5.2.3 in regards to the user-agent issue so i thought something happened there.
Later on i read a part about meteors way of handling server side code so i was thinking that maybe the
code needs to be on the server side now. i tested the login example code on https://docs.particle.io/reference/javascript/ and put it on serverside
and the server consol log gave me back a success login when i used my login
so i guess it works.
Could it be that everyone that have posted issues about this use meteor?
if someone could confirm this it would be nice.