0

I make fetch to server:

reader.onload = async function (e) {
(...)
     await fetch('/processImg', {
                    method: 'GET',
                }).then(function (res) {
                    console.log(res.text()); 
                })
                }).then(function (data) {
                    // console.log(data);
                });
(...)
}

And I get the following result:
Promise {< pending >}
__ proto__: Promise
[[PromiseState]]: "fulfilled"
[[PromiseResult]]: "done"
How can I get the 'done' value from [[PromiseResult]]? If needed I can provide more code (from server too)

al21
  • 39
  • 5
  • `res.text()` returns a promise itself. You need to wait for that one too with `.then`. – Sergiu Paraschiv May 04 '21 at 15:25
  • 2
    Does this answer your question? [fetch function return Promise ](https://stackoverflow.com/questions/54656223/fetch-function-return-promise-pending) - the only difference is that they get `json`, not `text`. – Sergiu Paraschiv May 04 '21 at 15:26
  • 1
    Related: [How do I return the response from an asynchronous call?](https://stackoverflow.com/q/14220321) | [Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference](https://stackoverflow.com/q/23667086) – VLAZ May 04 '21 at 15:28

0 Answers0