Search code examples
javascriptreactjsbigcommerce

How to access webdav files in the codebase in BigCommerce?


I have .js and .json files in webdav and I'm able to access them using cyberduck, however I'd like to import them in the codebase like this:

import File from "webdave/products/somefile";

I found a js package that I think will allow me to do that called webdav however I'm getting cors error when connecting to the client, and upon searching I discovered that BigCommerce does not allow api call to the store database?

Is there a way around it? basically I will be storing js files in webdav containing js objects for some product configurations, so I need those js objects in the codebase.


Solution

  • You can grab the files with an AJAX request, and use its contents within the success.

    $.ajax({
        type: 'GET',
        url: '/content/filname.json',
        dataType: 'json',
        success(data) { 
            console.log(data);
        },
    });