Languages
[Edit]
EN

Express.js - send json to node server

0 points
Created by:
Kia-H
546

In this article, we would like to show you how to get JSON from requests in Express.js.

The request data are passed in the request.body property. 

1. Get JSON from requests example

Edit

Note: it is required to add external library to run below example, so use:

JSON received from the client in the POST request:

Practical code:

Note: to read the JSON contained in the request, we must use express.json() middleware.

2. Pure JavaScript (Vanilla JS) AJAX POST request

Edit

The following is an example execution of a fetch method that sends JSON via POST request.

Alternative titles

  1. Express.js - receive JSON from requests
  2. Express.js - get JSON from requests
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join