import React, { Component } from "react"; import { BrowserRouter as Router } from 'react-router-dom'; import Route from 'react-router-dom/Route'; import axios from 'axios'; class Writing_Microblogs extends Component { constructor(props) { super(props); this.state = { value: '', title: '', topics: '', characterCount: 250 }; this.handleChange = this.handleChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); this.handleChangeforPost = this.handleChangeforPost.bind(this); this.handleChangeforTopics = this.handleChangeforTopics.bind(this); } handleChange(event) { this.setState( {title: event.target.value }); } handleChangeforTopics(event) { this.setState( {topics: event.target.value}); } handleSubmit(event) { // alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value); const response = axios.post( 'http://localhost:5001/twistter-e4649/us-central1/api/putPost', { body: this.state.value, userHandle: "new user", userImage: "bing-url", microBlogTitle: this.state.title, microBlogTopics: this.state.topics.split(', ') }, { headers: { 'Content-Type': 'application/json'} } ) console.log(response.data); alert('Post was shared successfully!'); event.preventDefault(); this.setState({value: '', title: '',characterCount: 250, topics: ''}) } handleChangeforPost(event) { this.setState({value: event.target.value }) } handleChangeforCharacterCount(event) { const charCount = event.target.value.length const charRemaining = 250 - charCount this.setState({characterCount: charRemaining }) } render() { return (