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

216
Visualizações
Vanilla JavaScript fetch request with Basic Auth and local .pem certificate (no node.js)

I'm very new to JavaScript so I'm hoping this is not a stupid question.

I have searched this site and the internet but cannot find the answer. I am trying to replicate a Python request.get() (which is working) in a JavaScript request. The python is:

requests.get(url, auth=(username, password), cert="path/to/certificate.pem")

My JavaScript is as follows currently:

fetch(url, {
  headers: {
    Authorization: `Basic ${btoa(username + ":" + password)}`
  },
  method: GET
})

How do I load the .pem certificate into the request?

Many thanks.

EDIT:

My apologies @Random Davis I thought specifying I'd searched this site was enough of an indication I hadn't found anything I was looking for. Please see below and the edited title.

To clarify I am not using node.js. Or at least I am unaware that I am using it as I am just utilising local files (HTML/CSS/JavaScript). As far as I can tell every single other answer here is node.js related and requires importing(??requiring??) external libraries. I am trying to avoid this.

Obviously if it is not possible without node.js and the external libraries I will have to think about using them. Due to my lack of knowledge with the JS/Node stack I am unaware if these requests can be done with just vanilla JS.

Again may thanks for any help.

about 4 years ago · Juan Pablo Isaza
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