0

I wrote a react-native app with an express.js backend. Now I wanted to create an asp.net (WebApi) backend for this app. Both have the same endpoints, but the response from the asp.net backend doesnt work in react-native. The response.json() gives me promise and not the json value.

I already changed the return type of my controller, but nothing changed. If I query the api with PostMan everything looks right.

In the app:

   fetch(`${URL}/job/load/${id}`)
            .then((response) => {
                const result = response.json();
                resolve(result);
            });

Controller:

   public object Load(int job) {
       bool exist = DoesJobExist(job);
       return Ok(new { exist = exist });
   }

The result should be { exist: true }

marius
  • 1
  • 2
  • Possible duplicate of https://stackoverflow.com/questions/39021870/fetch-returns-promise-instead-of-actual-data-even-after-using-then – abhinav pratap Oct 19 '19 at 17:31
  • Thanks you! Why is the second `.then()` not necessary when I receive the data from express.js? Because it is not async? – marius Oct 19 '19 at 17:46

0 Answers0