aboutsummaryrefslogtreecommitdiff
path: root/part2/phonebook/src/services/persons.js
diff options
context:
space:
mode:
Diffstat (limited to 'part2/phonebook/src/services/persons.js')
-rw-r--r--part2/phonebook/src/services/persons.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/part2/phonebook/src/services/persons.js b/part2/phonebook/src/services/persons.js
new file mode 100644
index 0000000..d65f4a3
--- /dev/null
+++ b/part2/phonebook/src/services/persons.js
@@ -0,0 +1,16 @@
+import axios from 'axios'
+const baseUrl = 'http://localhost:3001/persons'
+
+const getAll = () => {
+ return axios.get(baseUrl)
+}
+
+const create = (person) => {
+ return axios.post(baseUrl, person)
+}
+
+const update = (id, changedPerson) => {
+ return axios.put(`${baseUrl}/${id}`, changedPerson)
+}
+
+export default { getAll, create, update }