React JS Fetch Returns Empty Response but Postman Does Not
I've succeeded to fix it this way:
client-side (using React and Fetch-API)
const update = async (credentials, productData) => { try { let response = await fetch('/api/products/', { method: 'PUT', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + credentials.t }, body: productData }) return await response.json() } catch (err) { console.log(err) }}
server-side (Nodejs, Express with ):
app.use(bodyParser.json())app.use(bodyParser.urlencoded({ extended: true }));app.use(cors())...