Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

axios promise not resolved nor rejected #94

Open
shatodj opened this issue Jan 17, 2019 · 0 comments
Open

axios promise not resolved nor rejected #94

shatodj opened this issue Jan 17, 2019 · 0 comments

Comments

@shatodj
Copy link

shatodj commented Jan 17, 2019

It looks like using axios to get data from server is not working and it is stuck - no promise rejection or resolution is happening. I had to switch my data fetcher to classic fetch to get things work.

Test:

import axios from 'axios';

export function dataFetcher(url, data, params) {
  return axios({
    url,
    method: data ? 'POST' : 'GET',
    data,
    ...params,
  });
}

Somewhere in the code

async getRouteData(routePath, language) {
    try {
      console.log('before response'); // output is visible in console

      // get route data passing the cookies in request header
      const response = await dataFetcher(routePath, language);

      console.log('after response'); // output is NOT registered in console

      const route = response && response.data
      if (!route) {
        throw new Error('Invalid route data was retrieved by layout service.', routePath);
      }

      return response.data;
    } catch (error) {
      console.warn('getRouteData error', error);

      return null;
    }
}

Axios is working normally for react-native run-android.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant