DEV Community

Discussion on: Easily fetch data: react-api-hook

Collapse
 
pavermakov profile image
Pavel Ermakov

Add a few more requests and turn your components into an unreadable mess.

Collapse
 
demicdev profile image
Michele

What do you mean?

Collapse
 
pavermakov profile image
Pavel Ermakov

Can you run multiple requests in parallel? Can you chain one request to another?

Thread Thread
 
demicdev profile image
Michele

If you have to run multiple request, you only have to declare another hook:

const [stateFirst, sendFirst, cancelFirst] = useAPIHook(ENDPOINT1, configFirst);
const [stateSecond, sendSecond, cancelSecond] = useAPIHook(ENDPOINT2, configSecond);
Enter fullscreen mode Exit fullscreen mode