0

I went toward the answer provided for the question asked in the link below:

Multiple Controller Types with same Route prefix ASP.NET Web Api

To be able to have services within different controllers with the same names but different methods in Asp.net Web API.

I tested it and it worked perfectly with postman application, but when tried to use the same in a React application via Axios, got a network error.

the code to call the service is:

return function (dispatch) {    
    var url= ...
    const config = { headers: { 'Authorization': 'Bearer ' + sessionStorage.getItem('AccessToken') } };

    return new Promise((resolve, reject) => {
        axios.get(url, config).then((response) => {              

            dispatch({ type: 'FETCH_SUCCEED_' + param.Caller, payload: response.data })
            resolve(response.data);

        }).catch((error) => {             
            dispatch({ type: 'FETCH_ERROR_' + param.Caller, payload: error })
            reject(error);               
        })
    })
}

and the error I get is:

response: undefined message: "Network Error" stack: "Error: Network Error↵ at createError (http://localhost:3000/static/js/bundle.js:2195:15)↵ at XMLHttpRequest.handleError (http://localhost:3000/static/js/bundle.js:1724:14)"

Does anyone know about the solution of my problem?

Mary
  • 19
  • 6

0 Answers0