Axios API Calls
Mock API calls
Mock Calls
Berry utilizes mock data to display certain pages and actions, achieved using Axios. This allows for minimal modifications to be made when switching to live data. Users only need to change the mock API URL to the actual service URL.
How does it work?
Axios has been configured in the folder ..src\utils\axios.js
To use Axios on a page, you need to import it and make a call. After that, you need to make calls to Axios using axios.get('path')
or
axios.post('path')
see below implementation.
Berry has all dummy data in folder src\_mockApis.
For API, api/chat/users
, following data configured in ..\src_mockApis\chat\index.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