Answer the question
In order to leave comments, you need to log in
How to correctly learn JSON sent from the client to the server?
I send an array of data from the client via fetch:
const json = JSON.stringify(array)
fetch("/newarray", {
method: "POST",
body: json,
contentType: "application/json"
})
const express = require("express");
app.use(express.json())
app.post('/newarray', function(req, res) {
console.log(req.body);
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question