Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
Cannot execute context.route in for loop

I'm using route.abort() to block some URLs.

When I'm using code like this:

await this.context.route(/a.net/, route => route.abort());

works as expected.

BUT since I have a lot of routes to block instead of writing multiple lines of code above I wanted to create config with routes to block and execute await in for loop.

My config.ts like:

export const config = {
    use: {
        some_list: '/a.net/,/b.net/,/c.net/'
    },
};

rest of the code to block all routes from list:

let listOfResources = config.use.some_list.split(',')
for (let value of listOfResources) {
        await this.context.route(value, route => route.abort());
}

but in the above For loop the aborting or routes is not happening, could anyone help me with that?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

let endpoints = ['/a.net', '/b.net', '/c.net']

 endpoints.forEach((path) => {
      this.context.route(path, route => route.abort());
    });

I'm not very familiar with route.abort() function but maybe this could help.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda