Forum Discussion
_anomDiebolt_
7 years agoQrew Elite
Fetch is a JavaScript API that replaces XMLHTTPRequest and it is fully supported in all modern browsers:
Can I Use Fetch
https://caniuse.com/#feat=fetch
While Fetch is clearly the future there are some reasons you may not want to use it with QuickBase:
1) Fetch is a low level API and requies you send cookies (via credentials: "include") with each request.
2) With Fetch there is no corresponding $.ajaxSetup() method to include the application token with each request as there is with jQuery's AJAX methods
3) While Fetch returns a promise it is a native promise not a jQuery promise. Luckily you can convert a jQuery promise into a native promise using code similar to this:
The reasons to use Fetch are compelling:
1) There is a bug in the version of jQuery QuickBase uses (ver 1.7.1) which breaks chaining.
2) Service Workers only support Fetch (no XMLHTTPRequest or jQuery)
3) Just about every web related API is asynchronous today and returns a native promise. Since Fetch returns a native promise it works seamlessly with native promises.
4) Fetch support FormData which makes it trivial to clone a QuickBase form and submit it using Fetch as FormData
Can I Use Fetch
https://caniuse.com/#feat=fetch
While Fetch is clearly the future there are some reasons you may not want to use it with QuickBase:
1) Fetch is a low level API and requies you send cookies (via credentials: "include") with each request.
2) With Fetch there is no corresponding $.ajaxSetup() method to include the application token with each request as there is with jQuery's AJAX methods
3) While Fetch returns a promise it is a native promise not a jQuery promise. Luckily you can convert a jQuery promise into a native promise using code similar to this:
var nativePromise = Promise.resolve(4) Fetch does not support passing an object for the data (you have to pass a string, blob, formdata)
$.ajax(...);
);
The reasons to use Fetch are compelling:
1) There is a bug in the version of jQuery QuickBase uses (ver 1.7.1) which breaks chaining.
2) Service Workers only support Fetch (no XMLHTTPRequest or jQuery)
3) Just about every web related API is asynchronous today and returns a native promise. Since Fetch returns a native promise it works seamlessly with native promises.
4) Fetch support FormData which makes it trivial to clone a QuickBase form and submit it using Fetch as FormData
JoshuaTate
7 years agoQrew Cadet
With what Dan says above, i literally stopped using every other means of API calling, I live a life of promise chaining these days. With service workers you can post messages between your main thread and back handle the traffic on your site via routes, giving you the cool ability to clone your response stream, read it, modify it and serve it back in place of what quick-base was going to give you. As Dan has said many times, service workers give you full control but until you start trying to use them you just wont know the power (full power, total control) it gives you. People get scared hearing the term service workers. Check out work-box by google, its a good starting point.