lundi 18 janvier 2021

Fetch with Mocha.js in browser mode won't process or throw error

I'm pretty new to the whole 'modern' JS (implying, TS, TDD, Node...) so bear with me please :)

Anyhow, part of my app includes fetching data from the back-end and processing it with Three.js, I tried a lot of things from the docs, but each time it compiles fine, but nothing is displayed in the browser (nor in the console).

Also tried chai-as-promised, async syntax (but I understand that it's for Node)...

I'd love some pointers on what I'm doing wrong, I'm starting to wonder if that even possible, even though, as far as I know the code is valid JS, that [runs into my browser] (latest FF).

Thanks in advance.

it('A test what should fetch from the local api a json file', function(done) {
            // The url is just a random service I'm using for temporal test purpose
            fetch('https://baconipsum.com/api/?type=meat-and-filler')
                .then(function(response) {
                    return response.json();
                })
                .then(function(data) {
                    if (data) {
                        done();
                    } else {
                        done('err');
                    }
                });
        });

Aucun commentaire:

Enregistrer un commentaire