Re: [fetch] Option to require response.ok (#103)

It's a little more than that:

```js
installEvent.waitUntil(
  caches.open('static-v1').then(cache => {
    return Promise.all([
      '/hello/',
      '/world/'
    ].map(url => {
      let request = new Request(url);
      return fetch(request).then(response => {
        if (!response.ok) throw Error("NOT OK");
        return cache.put(request, response);
      });
    }));
  })
);

// vs…

installEvent.waitUntil(
  caches.open('static-v1').then(cache => {
    cache.addAll([
      '/hello/',
      '/world/'
    ].map(u => new Request(u, {requiredStatus: 'ok'})));
  })
);
```

Also, the former isn't atomic. This could just be an option in `cache.addAll` of course.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/103#issuecomment-128042443

Received on Wednesday, 5 August 2015 15:36:39 UTC