Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

214
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda