How to Create a REST API Without a Server

PHOTO EMBED

Wed May 29 2024 18:03:55 GMT+0000 (Coordinated Universal Time)

Saved by @saibrahmam #javascript

if ('serviceWorker' in navigator) {
  var scope = location.pathname.replace(/\/[^\/]+$/, '/')
  navigator.serviceWorker.register('sw.js', { scope })
    .then(function(reg) {
       reg.addEventListener('updatefound', function() {
         var installingWorker = reg.installing;
         console.log('A new service worker is being installed:',
                     installingWorker);
       });
       // registration worked
       console.log('Registration succeeded. Scope is ' + reg.scope);
    }).catch(function(error) {
      // registration failed
      console.log('Registration failed with ' + error);
    });
}
content_copyCOPY

https://www.freecodecamp.org/news/how-to-create-a-rest-api-without-a-server/?ref