HTTP request for local JSON file

Maybe I was just being stupid before, but I managed to get it working with Ionic File. Thanks to akshukla07 for giving the only source I could find that explained usage.

If anyone has a source that explains how Ionic File works with Android and iOS app filesystems I would hugely appreciate it!

 setupQuestionService() {
    this.file.readAsText(this.file.applicationDirectory + "www/assets/exams/oral", "oral-template.json")
    .then(res => {
      let data = (JSON.parse(res) as any).questions 
      for (let dataIndex=0; dataIndex<data.length; dataIndex++) { 
        let newQuestion = new OralQuestion(data[dataIndex].module, data[dataIndex].section, data[dataIndex].questionText, data[dataIndex].answerText)
        this.questions.push(newQuestion)
      }
    })
  }
1 Like