Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
¿Por qué el método de búsqueda de Javascript pone innecesario / en la URL?

Estoy enviando una solicitud GET con parámetros en la URL. El problema es que, al enviar una solicitud, la URL se modifica e incluye un "/" adicional que no es mío. También estoy usando Django.

Código:

 let url = `ajax_vehical_types`; groups.map(async (x, i) => { if (i === 0) url += `?group[${i}]=${x}`; else url += `&group[${i}]=${x}`; }); vehical_type = await fetch(`${window.location.origin}/${url}`) .then((res) => res.json()) .then((data) => data);

Aquí está el resultado Imagen que muestra la consola con solicitud de búsqueda

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede hacer uso de la interfaz URL . La ventaja de esto es que no necesita preocuparse por la construcción de su URL ni por la codificación de la URL.

Por favor vea el siguiente ejemplo:

 const groups = ["foo", "bar"]; const url = new URL(location.href); groups.forEach((x, i) => url.searchParams.append(`group[${i}]`, x)); vehical_type = await fetch(url.toString()) .then((res) => res.json()) .then((data) => data);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!