Skip to content

1.0.57 - The time update

Compare
Choose a tag to compare
@hazae41 hazae41 released this 04 Sep 13:04
· 799 commits to master since this release

BREAKING CHANGES

  • Renamed jsoneq to jsonEquals
  • Catched errors are no longer deduplicated or expired

CHANGES

  • You can now return a custom time in your fetcher
async function fetchAsJson<T>(url: string, more: XSWR.PosterMore<T>) {
  const { signal } = more

  const res = await fetch(url, { signal })
  const cooldown = Date.now() + (5 * 1000)
  const expiration = Date.now() + (10 * 1000)

  if (!res.ok) {
    const error = new Error(await res.text())
    return { error, cooldown, expiration } // implicit Date.now()
  }

  const data = await res.json() as T
  return { data, time: data.time, cooldown, expiration } // explicit date.time (milliseconds)
}
  • Fixed bugs