in our ios application using ionic angular v6 we loads assets files from a seperate server for image file we are not experiencing any corse issue, but for json files ( for lottie animations ) when i provide link i experience cors errors
<span class="analyze_img">
<lottie-player
slot="end"
autoplay
loop
[src]="https://otherdomain.com/male.json"
>
</lottie-player
></span>
to overcome this i used cordova ionic native plugin and loaded the json file seperately
this.http
.get(https://otherdomain.com/male.json, {}, {})
.then((response) => {
console.log('GET RESPONSE ==> ', response);
const data = response.data;
this.lottieFile = data;
console.log('LOTTTIE URL', data);
})
.catch((err) => {
console.log('http err', err);
});
i assigned this variable to lottie-player like below ,
at this time also it is not showing and also the failed to load yellow triangle also missing now?
<span class="analyze_img">
<lottie-player
slot="end"
autoplay
loop
[src]="lottieFile"
>
</lottie-player
></span>
i figured out that the lottifeFile variable isnot pure json object
it is some thing like below ,
//{"v":"5.9.6","fr":30,"ip":0,"op":124,"w":500,"h":500,"nm":"meter scale","ddd":0,"assets":[],"layers"
that is contains escape character, i tried by manually removing this escape character and hardcoding at this time it's working but
programatically removing escape character (response.data.replace(/\/g, '')) not removing here,
is there any alternative way to acheive this?