@midd What I exactly trying to do here is to implement this 2 JQuery Post/ Get calls to an API, the first authenticate the usage of the API and the 2nd shall pull data from the server through the API…I’ve spent hours trying to figure out how to implement them in my Emberjs app but with no clue, so if you can help that will be really great…thanks in advance
To auth the usage of the API:
$.ajax
({
type: "POST",
url: "http://portal.domainname.com/auth",
dataType: 'json',
async: false,
data: JSON.stringify({
Login: "logmein@email.com",
Password : "test"
}),
success: function(data) {
console.log(data); //Here I get the token needed for further calls...
},
error: function(xhr, error){
console.debug(xhr); console.debug(error);
}
});
The following shall load data in employee model:
$.ajax ({
type: "GET",
url: "http://portal.domainname.com/employees",
dataType: 'json',
async: false,
beforeSend: function (xhr) {
xhr.setRequestHeader ("Token", "0000000-0000-0000-0000-00000000");
},
success: function(data) {
console.log(data);
},
error: function(xhr, error){
console.debug(xhr); console.debug(error);
} });