It just silly and simple question. I just need the response data to proceed further ... But that's undefined..
Uncaught ReferenceError: url is not defined
self.addEventListener('push', function(event) {
console.log('Push message', event);
// perform action
fetch('slack-url')
.then(
function(response) {
if (response.status !== 200) {
console.log(response.status);
return;
}
// Examine the text in the response
response.json().then(function(data) {
console.log(data);
var url = data;
});
}
)
.catch(function(err) {
console.log('Fetch Error :-S', err);
});
var title = 'Push message';
var stack_url = url;
event.waitUntil(
self.registration.showNotification(title, {
stack_url:stack_url
})
);
});