suhaotian / xior

A lite request lib based on fetch with plugin support and similar API to axios.
https://www.npmjs.com/package/xior
MIT License
114 stars 1 forks source link

In next.js 14 fetch can accept extra options. Is it possible to send with xior?? #20

Closed shahreaz0 closed 1 week ago

shahreaz0 commented 1 week ago

Like this.

fetch('https://...', { next: { revalidate: 3600 } })
export default async function Page() {
  const res = await fetch('https://...', { next: { tags: ['collection'] } })
  const data = await res.json()
  // ...
}
suhaotian commented 1 week ago

Yes.

Above code in xior:

import xior from 'xior';
xior.get('https://...', { next: { revalidate: 3600 } })

// with POST
xior.post('https://...', {a: 1, ...data}, { next: { revalidate: 3600 } })
import xior from 'xior';
export default async function Page() {
  const res = await xior.get('https://...', { next: { tags: ['collection'] } })
  // const res = await xior.post('https://...', {}, { next: { tags: ['collection'] } })
  const {data} = res
  // ...
}
image

Same issue: https://github.com/developit/redaxios/issues/100