How to read Local JSON file in ionic V4?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to read Local JSON file in ionic V4?


this.http.get(‘assets/data/subtitles.json’).map(res => res.json()).subscribe(data =>
this.subtitles = data;
);



This is ionic v3 localJSON read code, I have used.



but ionic V3 type not supported to ionic V4





where did you import http from? Also are you getting any error logs in console?
– Suraj Rao
Aug 8 at 5:40


http




1 Answer
1



You can use fetch instead.




fetch('assets/data/subtitles.json').then(async res =>
this.subtitles = await res.json();
);






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard