Created
March 2, 2020 02:08
-
-
Save allefgomes/7fc608745b216ab95c22669866f3c99c to your computer and use it in GitHub Desktop.
Api service with axios-observable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Axios from "axios-observable"; | |
const url_base = "http://10.0.0.104:3000" | |
export default { | |
create(url, params) { | |
Axios.post(url_base + url, params) | |
.subscribe( | |
response => console.log(response), | |
error => { | |
console.log(error); | |
// TODO: Create a method to handle errors | |
} | |
); | |
}, | |
show(url) { | |
Axios.get(url_base + url) | |
.subscribe( | |
response => console.log(response), | |
error => { | |
console.log(error); | |
// TODO: Create a method to handle errors | |
} | |
); | |
}, | |
update(url, params) { | |
Axios.put(url_base + url, params) | |
.subscribe( | |
response => console.log(response), | |
error => { | |
console.log(error); | |
// TODO: Create a method to handle errors | |
} | |
); | |
}, | |
delete(url) { | |
Axios.delete(url_base + url) | |
.subscribe( | |
response => console.log(response), | |
error => { | |
console.log(error); | |
// TODO: Create a method to handle errors | |
} | |
); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment