D
D
Damir Balgabaev2020-03-07 14:54:27
Android
Damir Balgabaev, 2020-03-07 14:54:27

How to set up fetch in React Native?

React Navite throws this error:

Promise {
  "_40": 0,
  "_55": null,
  "_65": 0,
  "_72": null,
}

Here is the request code:
export const AuthLogin = async (data) => {
    console.log('Данные для сервера', data)
    try {
        let response = await fetch(`${initialUrl}/login`, {
            method: 'POST',
            headers: {Accept: 'application/json', 'Content-Type': 'application/json'},
            body: JSON.stringify(data)
        });
        let responseJson = await response.json();
        console.log('Пришли такие данные с сервера', responseJson)
        return responseJson;
    } catch (e) {
        console.log(`Ошибка на http ${e}`)
    }
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick, 2020-03-09
@BalgabayevD

It's not really a mistake, it's a representation of a promise in RN. Can you provide an example code using it? The async function itself also returns a promise. It looks like then is missing somewhere, it's hard to figure it out without the calling code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question