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

247
Views
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
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!