Trying to access response data using fetch

Okay, this works on my front end

fetch(request).then((response) => {
    console.log(response);
    response.json().then((data) => {
        console.log(data);
    });
});

The key part was the resolution of the promise chain.

Similar question here JavaScript fetch API - Why does response.json() return a promise object (instead of JSON)?


Could also split in to two like this

async fetchData() {
        let config = {
          headers: {
            'Accept': 'application/json'  //or text/json
          }
        }
        fetch(http://localhost:3000/add`, config)
          .then(res => {
            return res.json();
          }).then(this.setResults);

          //setResults
          setResults(results) {
          this.details = results;

          //or: let details = results

          console.log(details)  (or: this.details)