mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 10:18:48 +00:00
connected backend to frontend for writing microblogs
This commit is contained in:
parent
b1faacd312
commit
55dc62e57e
@ -1,15 +1,13 @@
|
||||
const admin = require('firebase-admin');
|
||||
/* eslint-disable promise/always-return */
|
||||
exports.putPost = (req, res) => {
|
||||
if (req.body.body.trim() === '') {
|
||||
return res.status(400).json({ body: 'Body must not be empty!'});
|
||||
}
|
||||
|
||||
|
||||
const newPost = {
|
||||
body: req.body.body,
|
||||
userHandle: req.body.userHandle,
|
||||
userImage: req.body.userImage,
|
||||
title: req.body.title,
|
||||
microBlogTitle: req.body.microBlogTitle,
|
||||
createdAt: new Date().toISOString(),
|
||||
likeCount: 0,
|
||||
commentCount: 0,
|
||||
|
||||
@ -19,7 +19,8 @@ const {
|
||||
|
||||
|
||||
// post routes
|
||||
app.post('/putPost', FBauth, putPost);
|
||||
//app.post('/putPost', FBauth, putPost);
|
||||
app.post('/putPost', putPost);
|
||||
|
||||
// users routes
|
||||
app.get('/getUser/:handle', getUserDetails);
|
||||
|
||||
@ -12,6 +12,7 @@ import register from './Register.js';
|
||||
import login from './Login.js';
|
||||
import user from './pages/user';
|
||||
import writeMicroblog from './Writing_Microblogs.js';
|
||||
import userLine from './Userline.js';
|
||||
|
||||
class App extends Component {
|
||||
render() {
|
||||
@ -25,6 +26,7 @@ class App extends Component {
|
||||
<Route exact path="/login" component={login}/>
|
||||
<Route exact path="/user" component={user}/>
|
||||
<Route exact path="/home" component={writeMicroblog}/>
|
||||
<Route exact path="/userline" component={userLine}/>
|
||||
</div>
|
||||
|
||||
</Router>
|
||||
|
||||
24
twistter-frontend/src/Userline.js
Normal file
24
twistter-frontend/src/Userline.js
Normal file
@ -0,0 +1,24 @@
|
||||
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 Userline extends Component {
|
||||
|
||||
constructor(props)
|
||||
{
|
||||
super(props);
|
||||
this.state = {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<p>Hi</p>
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Userline;
|
||||
@ -27,12 +27,19 @@ class Writing_Microblogs extends Component {
|
||||
|
||||
handleSubmit(event) {
|
||||
// alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value);
|
||||
const response = await axios.post(
|
||||
|
||||
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
|
||||
|
||||
},
|
||||
{ headers: { 'Content-Type': 'application/json'} }
|
||||
)
|
||||
console.log(response.data);
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user