Zapworks + database

I couldn’t find anything on the matter, how would I go about storing information in a database using ZapWorks Studio? Using, for example, pouchdb? Thank you.

2 Likes

Any response on this?

Three options that I know of

  1. You can use UniversalAR. With UniversalAR you can use any db library without issues or hackeries. Generally speaking anytime you need an external library, UAR is the way to go.
  2. Use Ajax to communicate with a database in Studio. You will need to use a proxy though.
  3. Use Firebase in Studio. This requires a bit of hackery and not everything works. But I managed to make cloud firestore and email authentication work, if that’s enough for you.
1 Like

I have been using restdb.io with Studio and haven’t had any problems. Now I haven’t tried it with WebAR. …

Steve

I have been using restdb.io with Studio and haven’t had any problems. Now I haven’t tried it with WebAR. …

Using the REST API I assume? No CORS issues?

I just used the Zappar Z.ajax code.
As for CORS the site gives you an API Key you just add.
Now like I said I haven’t tried it with WebAR yet just the Zappar app.

EX copy of some of my code…

export var GetDB = function() {
const ajaxParameters = {
url: “https://SITEINFO”,
method: “GET”,
headers: { ‘cache-control’: ‘no-cache’,
‘x-apikey’: ‘KEY’ },
timeout: 3000
}

// Perform the AJAX request
Z.ajax(ajaxParameters, (statusCode, data, request) => {
    
    if (statusCode === 0) {
            return;
        }
        if (statusCode < 200 || statusCode >= 300) {
            return;
        }
        // Attempt to parse the data returned from the AJAX request as JSON
        console.log("success!!!!");
        try {
            // https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse
            parsedData = JSON.parse(data);
            console.log(parsedData);
        }
        catch (e) {
            return;
        }
1 Like