Forum Discussion
NickWade
5 years agoQrew Cadet
@Harrison Hersch Are those client side apps hosted externally, or pages that are hosted as "QuickBase Pages"?
Myself and colleagues at my organization have not been able to leverage the QuickBase API directly from a client-side application.
Are there any examples that you could provide?
Below is a sample of what I would expect to work from a client-side app, but the result is this:
"Access to fetch at 'https://MY_QB_DOMAIN.quickbase.com/db/MY_APP_DB_ID' from origin 'chrome-search://local-ntp' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."
Myself and colleagues at my organization have not been able to leverage the QuickBase API directly from a client-side application.
Are there any examples that you could provide?
Below is a sample of what I would expect to work from a client-side app, but the result is this:
"Access to fetch at 'https://MY_QB_DOMAIN.quickbase.com/db/MY_APP_DB_ID' from origin 'chrome-search://local-ntp' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."
var myHeaders = new Headers(); myHeaders.append("Content-Type", "application/xml"); myHeaders.append("QUICKBASE-ACTION", "API_AddRecord"); var raw = "<qdbapi>\n <udata>MY_APPLICATION</udata>\n <apptoken>MY_APP_TOKEN_GOES_HERE</apptoken>\n <field fid=\"6\">nick</field>\n <field fid=\"7\">1234 MARKET ST</field>\n</qdbapi>"; var requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch("https://MY_QB_DOMAIN.quickbase.com/db/MY_APP_DB_ID", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));