0

So im trying to update a comment on my database using a "PUT" method in react

this is my function to fetch the api :

updateComment = () =>{
    const comments = this.state.updateComment;
    const i = this.state.selectedTicket.id;


    fetch(apiurl + "/Comment/" + i +"/update", {
        method: 'PUT',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
        },

        body: JSON.stringify({
            comments:comments,
        })
    })
        .then((response) => response.json())
        .then((responseJson) => {
            if (responseJson.status === "SUCCESS") {
                alert("Successfully updated comment")
            } else {
                alert("Could not update comment.")
            }
        })

}

this is my function to track the change in the editor

changeUpdateComment(event) {
    this.setState({updateComment: event});
}

and this is where i have the input for the editor

<button onClick={this.showEditor}>comment</button>
 {this.state.showEditor && (
<Editor

editorState={this.state.updateComment}
 toolbarClassName="toolbarClassName"
wrapperClassName="wrapperClassName"
editorClassName="editorClassName"
onEditorStateChange={this.changeUpdateComment}

/>
 )}

<button onClick={this.updateComment}>comment</button>

I keep on getting an Error exception of "Array to String" when trying to update the comment, any solutions?

0 Answers0