In this part, we will change how the HTTP methods will work with the new axios instances. Follow the instructions to do it correctly:
- Open the fetchApi.js file in the src/http folder.
- We will import the jsonPlaceholderApi function from baseFetch as an extra imported value:
import baseHttp, { jsonPlaceholderApi } from './baseFetch';
- We need to create a new constant called getTodos that will be exported. This constant will be a function that will receive a userId as a parameter and return the GET function from axios, with the userId parameter we just received, inside a configuration object in a property called params:
export const getTodos = async userId => jsonPlaceholderApi.get('todos',
{
params: {
userId,
},
});