Skip to content

axios promise not resolved nor rejected #94

@shatodj

Description

@shatodj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions