How to read Local JSON file in ionic V4?
Clash 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
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.
where did you import
http
from? Also are you getting any error logs in console?– Suraj Rao
Aug 8 at 5:40