score:1
Accepted answer
in your server, send as object:
res.send({ success: true });
and
res.send({ success: false });
in your frontend, get as:
fetch('/api/messages', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: json.stringify({ message: this.state.message })
})
.then(res => res.json())
Source: stackoverflow.com
Related Query
- React with express server giving me 400 on post
- Post an object with fetch using react js and express API server
- Hot reloading in a React app with express server
- fetch POST returns only _id object in Express API server React FrontEnd
- React Server side rendering with Express - warning on the client checksum & Styling
- Material-UI with Next.js & express giving Warning: Prop `className` did not match for server & client
- Setting up react with express server
- Axios POST request in react to Express server is returning 404
- Window is not defined with Server Side Rendering React and Express
- how do you start an express server with react on heroku?
- Express server with React front end routing without server side rendering
- 400 BAD REQUEST when POST using Axios in React with Nodejs/Express
- 400 Bad Request error with flask server react client for socketio
- Send data back to React client from Node server with POST request
- "How to fix Failed to load resource: the server responded with a status of 500 in React and express
- Problem making a post request in React and Express with Nodemailer
- Server side rendering with Webpack Express and React
- make post call to local express server in react
- How to POST and GET from mongoDB express server in react hooks?
- Using express post with react
- Cannot POST / error when trying to create a checkout session with Stripe + React + Express
- How to get data from React aplication on Express server to update meta-tags with data fetched from API
- Socket.io client not connecting with server React and Express
- Deployment of react app with express server gives blank screen but the app works fine with serve -s build
- React form POST to Express server not working - REST
- POST request error throwing 404 with node.js server and react app
- Suddenly started encountering Internal Server Error 500 on Mac for React App with Express server
- React app with express server shows just blanc page
- Fetch post api from React Client to express server causes error
- How to configure webpack dev server with react router dom v4?
More Query from same tag
- Unable to read a state from a reactjs component after it is set
- Why is e.preventDefault() making page refresh on submit?
- REACT: Map over nested array of objects
- configure React (build) routes.js with Django urls.py
- React component don't recognize function?
- Conditional statements in line in React.js (jsx)
- String manipulation in JS and React
- How to divide the logic between Redux reducers and action creators?
- How to pass onClick event to parent component when using iteration in ReactJS?
- How to display one value from many inputs randomly with React hooks
- react render input type checkbox not checked
- How to render list items in reactjs
- Why is it requiring two clicks to execute state change in react?
- Why is POST request with pool.query only works intermittently when using :id in the middle of URL?
- Add spaces in react-hook-forms while typing
- Tailwindcss nextjs JIT mode compile error
- Jest testing, keeps return undefined?
- Curtains Shader with react
- React Bootstrap clickable Form.Check
- Updating <canvas/> with React and setTimeout
- Button on card prevent new tab link from launching
- Adding image to aframe entity in React
- how to change state of 1 out of 3 components in react
- How to organize the business logic in React+Redux+thunk
- Server side rendering with async data fetch
- Render array of objects from Mongoose in React
- value of hook not update
- react getElementById is null
- use object in useEffect 2nd param without having to stringify it to JSON
- destructuring props with the rest properties