This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone git@github.com:jadjoubran/workbox-tutorial.git | |
cd workbox-tutorial | |
npm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class API{ | |
constructur(){ | |
//you could do advanced logic to determine the baseUrl | |
//based on the environment. Or you could simply pass it | |
//as an argument | |
this.baseUrl = 'http://laravel.dev/';//keep the slash at the end | |
} | |
fetch(url, options){ | |
return fetch(`${this.baseUrl}${url}`, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function run(){ | |
//other application logic here | |
const fetchPolyfill = 'https://rawgit.com/github/fetch/master/fetch.js'; | |
const fetchReady = await promyfill('fetch' in window, fetchPolyfill); | |
fetch('users.json'); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetchPolyfill = 'https://rawgit.com/github/fetch/master/fetch.js'; | |
const fetchReady = promyfill('fetch' in window, fetchPolyfill); | |
fetchReady.then(() => { | |
fetch('users.json'); | |
}); | |
//other application logic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetchPolyfill = 'https://rawgit.com/github/fetch/master/fetch.js'; | |
promyfill('fetch' in window, fetchPolyfill).then((fetch) => { | |
//fetch is available (polyfill is fetched only if needed) | |
fetch('users.json'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetchPolyfill = 'https://rawgit.com/github/fetch/master/fetch.js'; | |
promyfill('fetch' in window, fetchPolyfill).then(() => { | |
//fetch is available (polyfill is fetched only if needed) | |
fetch('users.json'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.config(['$compileProvider', function ($compileProvider) { | |
$compileProvider.debugInfoEnabled(false); | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
API.all('products').post({title, price}).then( (response) => { | |
var user = response.data.user; | |
}, (response) => { | |
//response.status | |
//response.data | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
API.all('products').post({title, price}).then( (response) => { | |
var user = response.data.user; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class APIService { | |
constructor(Restangular, ToastService) { | |
'ngInject'; | |
var headers = { | |
'Content-Type': 'application/json', | |
'Accept': 'application/x.laravel.v1+json' | |
}; | |
return Restangular.withConfig(function(RestangularConfigurer) { |