add forgotten comments controller
This commit is contained in:
parent
a53d397ac1
commit
ede5076def
20
src/controllers/comments.js
Normal file
20
src/controllers/comments.js
Normal 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}`)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user