0.0.4 • Published 5 months ago

mharj-etag-tools v0.0.4

Weekly downloads
6
License
LGPL-2.1-or-later
Repository
github
Last release
5 months ago

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));
}
0.0.4

5 months ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago