Changed api response "result" to "data"

This commit is contained in:
2018-11-07 16:05:21 +00:00
parent e2330974f6
commit 6c7376f2e8
27 changed files with 227 additions and 270 deletions

View File

@@ -15,36 +15,7 @@ function json(response) {
}
export default {
authenticate(login, password, cb) {
fetch(ayconfig.apiUrl + "auth", {
method: "post",
mode: "cors",
headers: {
Accept: "application/json, text/plain, */*",
"Content-Type": "application/json"
},
body: JSON.stringify({
login: login,
password: password
})
})
.then(status)
.then(json)
.then(function(data) {
console.log(
"AUTH.JS::authenticate() -> Request succeeded with JSON response",
data
);
cb(data);
//return data;
})
.catch(function(error) {
console.log("Request failed", error);
cb(error); //sb cb(data,error or something)
//return error;
});
},
async authenticatepromise(login, password) {
async authenticate(login, password) {
return fetch(ayconfig.apiUrl + "auth", {
method: "post",
mode: "cors",
@@ -60,14 +31,14 @@ export default {
.then(status)
.then(json)
.then(function(data) {
console.log(
"AUTH.JS::authenticatepromise() -> Request succeeded with JSON response",
data
);
// console.log(
// "AUTH.JS::authenticatepromise() -> Request succeeded with JSON response",
// data
// );
return data;
})
.catch(function(error) {
console.log("AUTH.JS::authenticatepromise() -> Request failed", error);
// console.log("AUTH.JS::authenticatepromise() -> Request failed", error);
//return error;
return Promise.reject(error);
});