i'm new in programming so bear with me. Need some help on calling API using angularjs here, and I think this have some problem with JSON Web Tokens; when trying to calling the API i get:
Login Object {success: true, data: Object}
Object {success: false, error: "User not logged in
$scope.login = function () {
var url = "";
url = 'http://localhost.net/api/login';
$.post(url, {email: "admin", password: "admin"}, function (data)
{
console.log("Login", data);
url = 'http://localhost.net/api/device/get';
$.post(url, {}, function (data)
{
console.log("Devices", data);
}).fail(function (data) {
console.log("Devices", "login_failed");
});
url = 'http://localhost.net/api/async';
$.post(url, {}, function (data)
{
console.log("Live Data", data);
}).fail(function (data) {
console.log("Live Data", "login_failed");
});
url = 'http://localhost.net/api/command/send';
$.post(url, {deviceId: 2, type: "Stop"}, function (data)
{
console.log("Command", data);
}).fail(function (data) {
console.log("Command", "login_failed");
});
}).fail(function (data) {
console.log("Login", "login_failed");
});
};