1
我试图添加一个服务工作人员到我的Rails应用程序与serviceworker宝石。ExecJS :: RuntimeError:SyntaxError:意外的标记:名称(catch)(行:41,col:8,pos:1392)
我一直在关注本指南https://rossta.net/blog/offline-page-for-your-rails-application.html并开始接收标题中列出的错误。
我回顾了其他类似的问题,但大多数都是由于语法错误。因为这篇文章Rails 5 Heroku deploy error: ExecJS::ProgramError: SyntaxError: Unexpected token: name (autoRegisterNamespace)
我的错误是由于通过serviceworker gem文件提供的令牌名称(catch)。
这里是我的代码,其中的错误发生...
function onFetch(event) {
// Fetch from network, fallback to cached content, then offline.html for same-origin GET requests
var request = event.request;
if (!request.url.match(/^https?:\/\/example.com/)) { return; }
if (request.method !== 'GET') { return; }
event.respondWith(
fetch(request). // first, the network
.catch(function fallback() {
caches.match(request).then(function(response) { // then, the cache
response || caches.match("/offline.html.erb"); // then, /offline cache
})
})
);
我理解的错误是在.catch,我只是不知道如何解决这个问题。
任何帮助非常感谢,谢谢!
这是它的()在获取结束时导致错误。我忽略了它,因为它没有提出有关语法问题。谢谢! –