diff --git a/src/components/messages.js b/src/components/messages.js index 8c472c1..ea494a0 100644 --- a/src/components/messages.js +++ b/src/components/messages.js @@ -34,24 +34,43 @@ class Messages extends React.Component{ }); - fetch(`http://localhost:3000/api/v1/message/${this.context.user.ID}`, { - headers: { - "Authorization": this.context.user.Authorization, - } - }) - .then(status) - .then(json) - .then(data => { - console.log(data) - this.setState({messages:data}) - }) - .catch(errorResponse => { - alert("Creation failed" +errorResponse) - console.log('Creation failed'); - alert(`Error: ${JSON.stringify(errorResponse)}`); - }); + fetch(`http://localhost:3000/api/v1/message/${this.context.user.ID}`, { + headers: { + "Authorization": this.context.user.Authorization, + } + }) + .then(status) + .then(json) + .then(data => { + console.log(data) + this.setState({messages:data}) + }) + .catch(errorResponse => { + alert("Creation failed" +errorResponse) + console.log('Creation failed'); + alert(`Error: ${JSON.stringify(errorResponse)}`); + }); }; + + + + delete(ID){ + fetch(`http://localhost:3000/api/v1/message/${ID}`, { + method: "DELETE", + headers: { + "Authorization": this.context.user.Authorization, + } + }) + .then(status) + .then(data => { + console.log(data) + }) + .catch(errorResponse => { + console.log('Delete failed'); + alert(`Error: ${JSON.stringify(errorResponse)}`); + }); + } @@ -77,6 +96,7 @@ class Messages extends React.Component{

User{message.authorID}:

{message.allText}

+ ) diff --git a/src/components/reply.js b/src/components/reply.js index 547221a..1184903 100644 --- a/src/components/reply.js +++ b/src/components/reply.js @@ -51,7 +51,6 @@ class Reply extends React.Component{ render() { return (
-

{this.props.location.state.data.ID}