¿Cómo integrar Axios con Next 14 de manera eficiente? ¿Algún consejo o ejemplo práctico?

14 Replies, 904 Views

Hey there! I’ve been using Axios con Next 14 in API routes, and it’s been working great for me. It keeps the frontend clean and lets you handle all the logic server-side.

For caching, I’d suggest looking into `swr` or `react-query`. They integrate seamlessly with Next.js and make caching a breeze.

Here’s a quick example of using Axios in an API route:
```javascript
export default async function handler(req, res) {
const response = await axios.get('https://api.yoursite.com/data');
res.status(200).json(response.data);
}
```
Hope this gives you some ideas!

Messages In This Thread



Users browsing this thread: 1 Guest(s)