Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Savy011/fullstackopen-exercises. My Exercise Submissions for FullStack Open fullstackopen.com/en
Something went wrong. Try again.
571 B · 23 lines
JavaScript
at main
1234567891011121314151617181920212223import axios from 'axios'
const baseUrl = 'http://localhost:3001/anecdotes'
export const getAnecdotes = async () => { const response = await axios.get(baseUrl)
return response.data}
export const postAnecdote = async content => { const postObj = { content, votes: 0 } const response = await axios.post(baseUrl, postObj)
return response.data}
export const updateAnecdote = async obj => { const updatedObj = { ...obj, votes: obj.votes + 1 } const response = await axios.put(`${baseUrl}/${obj.id}`, updatedObj)
return response.data}