- From: Jake Archibald <notifications@github.com>
- Date: Mon, 13 Apr 2015 10:04:26 -0700
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
Received on Monday, 13 April 2015 17:04:54 UTC
Hmm, having it on request would avoid the…
```js
fetch(url).then(response => {
if (!response.ok) throw Error("NAH");
// etc
})
```
…boilerplate. It would make the cache code:
```js
cache.addAll(
urls.map(u => new Request(u, {ensureOk: true}))
);
```
…which is a bit more verbose, but it would allow:
```js
cache.addAll([
'/hello/',
'/world/',
new Request('//other-origin/blah.txt', {mode: 'no-cors'})
].map(request => {
if (request instanceof Request) return request;
return new Request(url, {ensureOk: true});
}));
```
…meaning you could mix `ensureOk` requests with others.
---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/407#issuecomment-92425679
Received on Monday, 13 April 2015 17:04:54 UTC