mharj-etag-tools
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

mharj-etag-tools

Cache validation example with state (i.e. redux)

const {todo} = getState();
const headers = new Headers();
if (haveETag(todo)) {
	headers.set('if-none-match', getETag(todo));
}
const res = await fetch('https://jsonplaceholder.typicode.com/todos/1', {headers});
if (res.status === 200) {
    const data = await res.json();
	const todoEtagObject = wrapEtag(data, getEtagHeader(res));
	dispatch(storeTodo(todoEtagObject));
}

Readme

Keywords

Package Sidebar

Install

npm i mharj-etag-tools

Weekly Downloads

6

Version

0.0.4

License

LGPL-2.1-or-later

Unpacked Size

36.2 kB

Total Files

5

Last publish

Collaborators

  • mharj