This commit is contained in:
12
app/ayanova/src/api/apiutil.js
Normal file
12
app/ayanova/src/api/apiutil.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
export default {
|
||||||
|
status(response) {
|
||||||
|
if (response.status >= 200 && response.status < 300) {
|
||||||
|
return Promise.resolve(response);
|
||||||
|
} else {
|
||||||
|
return Promise.reject(new Error(response.statusText));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
json(response) {
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,22 +1,22 @@
|
|||||||
/*eslint-disable*/
|
/*eslint-disable*/
|
||||||
import ayconfig from "../utils/config";
|
import config from "../utils/config";
|
||||||
|
import api from "./apiutil";
|
||||||
|
|
||||||
function status(response) {
|
// function status(response) {
|
||||||
if (response.status >= 200 && response.status < 300) {
|
// if (response.status >= 200 && response.status < 300) {
|
||||||
return Promise.resolve(response);
|
// return Promise.resolve(response);
|
||||||
} else {
|
// } else {
|
||||||
return Promise.reject(new Error(response.statusText));
|
// return Promise.reject(new Error(response.statusText));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
function json(response) {
|
// function json(response) {
|
||||||
var v = response.json();
|
// return response.json();
|
||||||
return v;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async authenticate(login, password) {
|
async authenticate(login, password) {
|
||||||
return fetch(ayconfig.apiUrl + "auth", {
|
return fetch(config.apiUrl + "auth", {
|
||||||
method: "post",
|
method: "post",
|
||||||
mode: "cors",
|
mode: "cors",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -28,18 +28,12 @@ export default {
|
|||||||
password: password
|
password: password
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(status)
|
.then(api.status)
|
||||||
.then(json)
|
.then(api.json)
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
// console.log(
|
|
||||||
// "AUTH.JS::authenticatepromise() -> Request succeeded with JSON response",
|
|
||||||
// data
|
|
||||||
// );
|
|
||||||
return data;
|
return data;
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
// console.log("AUTH.JS::authenticatepromise() -> Request failed", error);
|
|
||||||
//return error;
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ NEXT: Test authorization code to login even if just doing it from code for now t
|
|||||||
- Stage 2:
|
- Stage 2:
|
||||||
- Make it work with the backend:
|
- Make it work with the backend:
|
||||||
- Login, logout
|
- Login, logout
|
||||||
|
- Error handling at client (log? display?)
|
||||||
- Notification of some kind (bell / toast)
|
- Notification of some kind (bell / toast)
|
||||||
- Localized text
|
- Localized text
|
||||||
- About page with license info
|
- About page with license info
|
||||||
|
|||||||
Reference in New Issue
Block a user