尽管看起来正确,但在我的服务工作文件中出现语法错误

时间:2017-06-16 11:12:35

标签: javascript service-worker

self.addEventListener('sync', function(event) {
    event.waitUntil(getAllData().then(function(messages) {
        messages.map(function(msg) {
        fetch('/storeMessage.php?user='+msg.user+'&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
);
});

这是我得到的错误:

Uncaught SyntaxError: missing ) after argument list

我没有经常使用异步JS。任何帮助将不胜感激

0 个答案:

没有答案