React JS Fetch Returns Empty Response but Postman Does Not React JS Fetch Returns Empty Response but Postman Does Not laravel laravel

React JS Fetch Returns Empty Response but Postman Does Not


.json is a function and needs to be invoked. Try..

.then(response => response.json())

You're currently returning the .json parsing function.


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())...