I am using a npm module called lottie-web which basically gives you a svg animation ,if you give it a json data file which i get from the adobe after effects(to keep things short all it does is takes a html element by its id and in the path it takes a json data file and loads the svg in the given element).I am using a node application with express and using handlebars(hbs) to render the frontend to the browser, So in this case we need to attach a script tag of the lottie-web cdn link or the other way is we can use browserify to convert the given file below and run browserify myfilename -o bundle.js command and then use the bundle.js in the script tag to load the js in the client side
const bodymovin = require('bodymovin')
var animation = bodymovin.loadAnimation({
container: document.getElementById('loader'),
renderer: 'svg',
loop: true,
autoplay: true,
path: '../../public/js/loader.json'
})
If i go with the first approach (i.e using a cdn link) i am getting a the following error lottie.js:4406 Uncaught DOMException: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'json'). at formatResponse (https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.6.10/lottie.js:4406:17) at XMLHttpRequest.xhr.onreadystatechange (https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.6.10/lottie.js:4424:26)
and if i go with the second approach (i.e using a browserify bundled js file) i am getting the following error VM2609:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse () at XMLHttpRequest.xhr.onreadystatechange (bundle.js:8583)
but if i try it using a cdn link in a normal html file and adding a js file to run the code given above (i.e outside my folder structure in a normal html css js structure it works fine). Can someone point me out where i am going wrong,thanks in advance.