import axios from 'axios';
export const loadJsonHttp = (url, resObj) => {
return fetch(url, resObj)
.then(response => {
if (response.status >= 200 && response.status < 300) {
return Promise.resolve(response)
} else {
return Promise.reject(new Error(response.statusText))
}
})
.then(response => {
response.json();
});
}
export const loadJsonLocal = (url, resObj) => {
return axios.get(url)
.then(function(res) {
var nodes;
nodes = res.data;
var nodesArray = Object.keys(nodes).map(function(k) { return nodes[k] });
return nodesArray;
})
.catch(function(error){
console.log(error);
});
}
Created
July 10, 2018 16:13
-
-
Save andrit/63577e2d13425d9814211d1295c3c81b to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment