in tweeter/src/components/Tweets.js [42:58]
async addTweet() {
const response = await fetch("api/tweets/", {
method: "POST",
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': Cookies.get('csrftoken')
},
body: JSON.stringify({
text: this.state.addTweetText
})
})
const data = await response.json();
const newTweets = Object.assign([], this.state.tweets);
newTweets.unshift(data)
console.log(newTweets)
this.setState({tweets: newTweets, addTweetText: ''})
}