Skip to content

A queue for service workers which send requests to a restful API

Notifications You must be signed in to change notification settings

lucas42/restful-queue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

restful-queue

A queue for service workers which send requests to a restful API

Basic usage

Add the following to your service worker to use the queue for all non-GET requests:

import { queueAndAttemptRequest } from 'restful-queue';

self.addEventListener('fetch', event => {
	if (event.request.method !== 'GET') {
		event.respondWith(queueAndAttemptRequest(event.request));
	} else {
		... // Handle GET requests here, eg return them from cache
	}
});

See also

Unit Testing

Run:

npm test

Publish to npm

Automatically publishes on the main branch

Make sure to bump the version number in package.json. (Can use npm version ${version_number}).

About

A queue for service workers which send requests to a restful API

Resources

Stars

Watchers

Forks

Packages

No packages published