How do I use fetch?

  • 0
    In short, I have this thing:
    var audio = new Audio();
    audio.src = "http://mus.com/song.mp3";
    audio.play();
    var lirycs = [{
    "time": 5444,
    "duration": 121,
    "text": "Top ",
    "isLineEnding": 0
    },
    {
    "time": 6000,
    "duration": 121,
    "text": "Top2 ",
    "isLineEnding": 0
    }];
    var next_text = lirycs.shift();
    var checker = setInterval(function(){
        if(next_text.time<audio.currentTime*1000){
            console.log(next_text.text);
            next_text = lirycs.shift();
        }
        if(audio.ended)clearInterval(checker);
    });


    There JSON is in a variable, that is, it is written in it, how can I do so that I can connect json to this variable along the way. Typically, so that you need to specify the path to the json file, and its contents were in a variable
    JavaScript Anonymous, Oct 4, 2020

  • 1 Answers
  • 0
    fetch ('file path')
    Atticus Frey

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!