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*/
|
||||
import ayconfig from "../utils/config";
|
||||
import config from "../utils/config";
|
||||
import api from "./apiutil";
|
||||
|
||||
function status(response) {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return Promise.resolve(response);
|
||||
} else {
|
||||
return Promise.reject(new Error(response.statusText));
|
||||
}
|
||||
}
|
||||
// function status(response) {
|
||||
// if (response.status >= 200 && response.status < 300) {
|
||||
// return Promise.resolve(response);
|
||||
// } else {
|
||||
// return Promise.reject(new Error(response.statusText));
|
||||
// }
|
||||
// }
|
||||
|
||||
function json(response) {
|
||||
var v = response.json();
|
||||
return v;
|
||||
}
|
||||
// function json(response) {
|
||||
// return response.json();
|
||||
// }
|
||||
|
||||
export default {
|
||||
async authenticate(login, password) {
|
||||
return fetch(ayconfig.apiUrl + "auth", {
|
||||
return fetch(config.apiUrl + "auth", {
|
||||
method: "post",
|
||||
mode: "cors",
|
||||
headers: {
|
||||
@@ -28,18 +28,12 @@ export default {
|
||||
password: password
|
||||
})
|
||||
})
|
||||
.then(status)
|
||||
.then(json)
|
||||
.then(api.status)
|
||||
.then(api.json)
|
||||
.then(function(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);
|
||||
//return 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:
|
||||
- Make it work with the backend:
|
||||
- Login, logout
|
||||
- Error handling at client (log? display?)
|
||||
- Notification of some kind (bell / toast)
|
||||
- Localized text
|
||||
- About page with license info
|
||||
|
||||
Reference in New Issue
Block a user