mirror of
https://github.com/10h30/fullstackopen.git
synced 2026-06-05 15:08:33 +09:00
31 lines
677 B
JavaScript
31 lines
677 B
JavaScript
import axios from 'axios'
|
|
|
|
|
|
const baseUrl = 'http://localhost:3001/persons'
|
|
|
|
const getContact = () => {
|
|
const contact = axios.get(baseUrl)
|
|
return contact.then(response => response.data)
|
|
}
|
|
|
|
|
|
const updateContact = newPerson => {
|
|
const contact = axios.post(baseUrl, newPerson)
|
|
return contact.then(response => response.data)
|
|
}
|
|
|
|
const deleteContact = id => {
|
|
const contact = axios.delete(`${baseUrl}/${id}`)
|
|
return contact.then(response => response.data)
|
|
}
|
|
|
|
/*
|
|
const update = (id, newObject) => {
|
|
return axios.put(`${baseUrl}/${id}`, newObject)
|
|
}*/
|
|
|
|
const Contact = {
|
|
getContact, updateContact, deleteContact
|
|
}
|
|
|
|
export default Contact |