Cannot make real calls with axiom

Closed
G General August 16, 2022
Login to reply
Coded Themes Support Agent
2 years ago

Hello, Davide Cremonesi,

- Replace below code in  axios.ts file at '../src/utils/' and for real call use Axios and for local use axios.

import axios from 'axios';
const axiosServices = axios.create();
// ==============================|| AXIOS - FOR MOCK SERVICES ||============================== //
axiosServices.interceptors.response.use(
  (response) => response,
  (error) => Promise.reject((error.response && error.response.data) || 'Wrong Services')
);
export default axiosServices;
// ==============================|| AXIOS - FOR REAL REQUEST ||============================== //
export const Axios = axios.create({ withCredentials: true });

If still you have any other query, contact us.

Regards,
Amit Gorasiya

Davide Cremonesi
2 years ago

I changed axios.ts file to make calls to my backend APIs

const axiosServices = axios.create({

    baseURL: 'http://localhost:8088/swarm-api/'

});

and in my code I call a hook to fetch real data

  useEffect(() => {

    axios.get('dashboard/assetClassMenus')

        .then(res => console.log(res))

        .then((res) => setData([]));

  }, [])

but in the chrome dev tools I see the "Wrong Services" error is thrown and in the network tab there is no trace of the call to the backend. Is something preventing the call to be made? Maybe some mock configuration must be switched off? If I use simple fetch calls it works.

Additional Info

Order#: 48864

Purchase From?: mui store

Name of Product/template: Mantis