Send many requests with Xios without the code waiting for the answer of previous requests

Asked

Viewed 80 times

-2

Good morning.

I want to send many requests without the code waiting for the previous requests to be answered using Xios.

My current code name:

new Vue({
    el: '#central',
    data: {
        estilo: 'resize:none;text-align:center;color:red;width:450px;height:200px;font-size:15px;',
        capkey: 'text-align:center;color:RED;font-size:17px;;width:20%;height:40%;',
        ativar: true,
        buttonvalue: 'Inserir lista',
        livestyle: 'color:#519872;font-size:17px;',
        diestyle: 'color:#fd2eb3;font-size:17px',
        lives: [],
        dies: [],
    },
    methods: {

        async testar(rsrsrs) {
            await axios.get('http://localhost/fg/nova.php', {
                crossDomain: true,
                params: {
                    lista: rsrsrs
                }
            })
                .then((response) => {
                    console.log(response.data);
                    var resp = response.data.msg;
                    console.log(resp)

                    if (resp.includes("Live")) {
                        this.lives.push(resp)
                    } else if (resp.includes("reCaptcha")) {
                        this.testar(rsrsrs)
                    } else {
                        this.dies.push(resp)
                    }


                })
                .catch(function (error) {
                    console.log(error);
                })
        },

        checkin(e) {
            this.buttonvalue = 'Testar'
            this.ativar = false
            var lista = e.split('\n');

            lista.map((value, key) => {

                this.testar(value);

            });


        }
    }
})

The problem is that the browser/code is waiting for the answers of the first requests and thus taking a long time to process a certain amount of requests!

How can I send and return requests in parallel or synchronously ?

  • Hey, Wagner, tip: either the title doesn’t match the doubt, or it’s wrong. Because the title talks about request in Next, but internally you put Vuejs in play, try to put an example of the problem without Vue if the doubt is really about Next.

  • Remove the await of the line await axios

1 answer

2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.