diff --git a/twistter-frontend/src/Writing_Microblogs.js b/twistter-frontend/src/Writing_Microblogs.js
index 9cac7b7..4d7484d 100644
--- a/twistter-frontend/src/Writing_Microblogs.js
+++ b/twistter-frontend/src/Writing_Microblogs.js
@@ -40,15 +40,28 @@ class Writing_Microblogs extends Component {
};
axios
- .post("/putPost", postData, headers)
+ .post("/putPost", postData, headers) // TODO: add topics
.then(res => {
- alert("Post was shared successfully!");
+ // alert("Post was shared successfully!");
console.log(res.data);
})
.catch(err => {
alert("An error occured.");
console.error(err);
});
+ console.log(postData.microBlogTopics);
+ postData.microBlogTopics.forEach(topic => {
+ axios
+ .post("/putTopic", {
+ following: topic
+ })
+ .then(res => {
+ console.log(res.data);
+ })
+ .catch(err => {
+ console.error(err);
+ });
+ });
event.preventDefault();
this.setState({ value: "", title: "", characterCount: 250, topics: "" });
}
diff --git a/twistter-frontend/src/pages/Home.js b/twistter-frontend/src/pages/Home.js
index 0602a3a..f08543e 100644
--- a/twistter-frontend/src/pages/Home.js
+++ b/twistter-frontend/src/pages/Home.js
@@ -1,13 +1,13 @@
/* eslint-disable */
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
-import { connect } from 'react-redux';
-import axios from 'axios';
+import React, { Component } from "react";
+import PropTypes from "prop-types";
+import { connect } from "react-redux";
+import axios from "axios";
// Material UI and React Router
-import Grid from '@material-ui/core/Grid';
-import Card from '@material-ui/core/Card';
-import CardContent from '@material-ui/core/CardContent';
+import Grid from "@material-ui/core/Grid";
+import Card from "@material-ui/core/Card";
+import CardContent from "@material-ui/core/CardContent";
import Typography from "@material-ui/core/Typography";
// component
@@ -31,7 +31,7 @@ class Home extends Component {
console.log(res.data);
this.setState({
posts: res.data
- })
+ });
})
.catch(err => console.log(err));
}
@@ -41,17 +41,22 @@ class Home extends Component {
let authenticated = this.props.user.authenticated;
let username = this.props.user.credentials.handle;
let postMarkup = this.state.posts ? (
- this.state.posts.map(post =>
+ this.state.posts.map(post => (
) :
- (
)
- }
+ {this.state.imageUrl ? (
+
+ ) : (
+
+ )}
+
My Posts
); + )) + ) : ( +Loading post...
+ ); - return ( - authenticated ? + return authenticated ? (