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

260
Vistas
Why does my fetch request url return a 400 Bad Request even though the url works on swagger?

The console tells me: "Failed to load resource: http://localhost:3010/v0/channelsch... the server responded with a status of 400 (Bad Request)."

However on Swagger the request works with the exact same parameters.

The request url the console shows was used: request url console shows

The request url I enter on SwaggerUI is: Swagger UI req url

I used a website online to compare the string and they are the same. Anything that could cause this 400 Bad Request? Or how else can I pass my information without having to use query parameters?

I tried to use fetch like so:

  const pushToChatlog = () => {
    try {
      if (Object.values({clickedDms})[0] === 'false') {
        const param1 = parseInt(userObj.id);

        let param2 = Object.values({currentWorkspace})[0];
        param2 = param2.replace(/\s{1}/g, '%20');
        param2 = param2.replace(/#/g, '%23');

        let param3 = Object.values({currentChannel})[0];
        param3 = param3.replace(/\s{1}/g, '%20');
        param3 = param3.replace(/#/g, '%23');

        let param4 = currentInput;
        param4 = param4.replace(/\s{1}/g, '%20');
        param4 = param4.replace(/#/g, '%23');
        param4 = param4.replace(/!/g, '%21');

        fetch(`http://localhost:3010/v0/channelschat?ident=${param1}&ws=${param2}&cn=${param3}&content=${param4}`);
      } else if (Object.values({clickedDms})[0] === 'true') {
        console.log('pushing to dms!!!');
        const param1 = parseInt(userObj.id);
        const param2 = Object.values({clickedUserId})[0];

        let param3 = Object.values({currentWorkspace})[0];
        param3 = param3.replace(/\s{1}/g, '%20');
        param3 = param3.replace(/#/g, '%23');

        let param4 = currentInput;
        param4 = param4.replace(/\s{1}/g, '%20');
        param4 = param4.replace(/#/g, '%23');
        param4 = param4.replace(/!/g, '%21');

        fetch(`http://localhost:3010/v0/dmschat?id=${param1}&idWith=${param2}&ws=${param3}&content=${param4}`);
      }
    } catch (e) {
      console.log(e);
    }
  };
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