Failed login with particle-api-js


I’m trying to login using the following particle-api-js reference code:

function foo() {
var email = document.getElementById(‘uname’).value;
var password = document.getElementById(‘upassword’).value;
var particle = new Particle();
particle.login({username: email, password: password, tokenDuration: 900}).then(
console.log('API call completed on promise resolve: ', data.body.access_token);
function(err) {
console.log('API call completed on promise fail: ', err);

The chrome console prints the following error:

API call completed on promise fail: Object {statusCode: undefined, errorDescription: “Network error undefined from /oauth/token”, error: Error: Request has been terminated
Possible causes: the network is offline, Origin is not allowed by…, body: undefined}

I have particle.min.js downloaded locally and it is included in my .html file. I’ve also tried to include it by using the following src:


The error is the same.

The Web Application is hosted on a LAMP (Linux Apache MySql PHP) setup.

Any help is much appreciated.