title: Getting a syntax error in my service worker file even though it seems correct
body: <pre><code>self.addEventListener('sync', function(event) {
      event.waitUntil(getAllData().then(function(messages) {
          messages.map(function(msg) {
          fetch('/storeMessage.php?user='+msg.user+'&amp;message='+msg.message,{
            method: 'GET',
            headers: new Headers()
          }).then(function(response) {  
            return response.text();
          }).then(function(data) {
            if (data === 'success') {
              var request = self.indexedDB.open("db1",2);
              request.onerror = function(event) {
              alert("Why didn't you allow my web app to use IndexedDB?!");
              reject('Failure!');
              };
             request.onsuccess = function(event) {
             db = event.target.result;
             db.transaction("messages","readwrite").objectStore("messages").delete(msg.id);
              };
            }
          });
      });
  });//the line with error
  );
  });
  </code></pre>
  
  <p>This is the error i am getting:</p>
  
  <pre><code>Uncaught SyntaxError: missing ) after argument list
  </code></pre>
  
  <p>I have not used async JS very often. Any help will be appreciated</p>