CacheMissErrorAn Error that represents a cache miss.
import { CacheMissError } from 'bestfetch';One of the options that you can pass to bestfetch is cachePolicy. If you specify your policy to be "cache-only" and no response exists in the cache, then the Promise will reject.
The error that is passed to the .catch() callback will be an instance of CacheMissError.
You can use the CacheMissError to determine if a cache miss is the cause of the Promise's rejection.
bestfetch('https://jsonplaceholder.typicode.com/todos/1', {
cachePolicy: 'cache-only'
})
.catch(err => {
if (err instanceof CacheMissError) {
console.log('This request did not have a response in the cache.');
}
});