add forgotten comments controller

This commit is contained in:
data 2019-10-06 05:28:31 +01:00
parent a53d397ac1
commit ede5076def

View File

@ -0,0 +1,20 @@
import axios from 'axios'
const API = process.env.REACT_APP_API || 'http://localhost:1337'
export async function replyToComment(e) {
e.preventDefault()
const user = {} // TODO update properties from form
console.log(e.target)
try {
const { data, error } = await axios.put(API + `/api/user`, user)
console.log('Trying to update user profile: ', user)
if (error) {
alert('Received error when updating user profile: ', error)
} else if (data) {
this.setState({ user: data })
console.log('Successfully updated user profile:', data)
}
} catch (e) {
alert(`Updating user profile failed: ${e}`)
}
}