Axios API Calls
Mock API calls
Mock Calls
Mantis uses fack/mock data to render some pages and actions. Mocking has been achieved with help of Axios. It helps users to do minimal changes to load live data. Users just need to change the mock API URL to the Live service URL.
How does it work?
Axios have been configured in the folder ..src\utils\axios.js
To use Axios on a page, you need to import it and make a call. It is used from slices here: src\store\reducers.
You need to call slice action from your page like below:
Mantis has all dummy data in the folder src\data.
For API, api/chat/users
, following data configured in ..\src\data\chat.js
:
You can configure the same for post
methods as well.
Next JS
Next js has a different mechanism to handle API. We have created src/pages/api
folder where all the API stays. Whenever a request happened to API, this will be called. for more about API in nextJS, please refer: https://nextjs.org/docs/api-routes/introduction
Last updated