Axios API Calls
Mock API calls
Mock Calls
Berry 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 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