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

280
Visualizações
location.search is undefined but location is where the application runs

I have this code in my application.

const queryString = require('query-string');
const parsed = queryString.parse(location.search);
return this.docListingService.getPacks(parsed.policy).then(packs => {
    this.setState({ isLoading: false, packs });
    return packs;
}).catch((error) => {
    this.loggingService.logError('Error returning Docs ' + error);
    this.setState({ errorOccured: true});
});

It doesn't work because location.search is undefined.

I can see that location is http://localhost:3000/ which is where this application is running. How can/should this be set?

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

0

You can't using dot notaion on strings!

Based on this You can try this (if you are using react hooks), first of all define location: const location = useLocation();

about 4 years ago · Juan Pablo Isaza Relatório

0

Try to investigate a little bit:

  • https://developer.mozilla.org/en-US/docs/Web/API/Location/search
  • https://www.w3schools.com/jsref/prop_loc_search.asp

Location search is a funtion that returns the queryString of the url. you dont have a queryString in your URL ..your/whole/url?queryStringOverHere=something

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