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

138
Views
In chrome extension popup.html fetch to localhost send request to popup.html

I want to log in user within a popup.html. When I am doing by fetch request to my Back-end authenticate , request goes to local popup.html?email=eee@mail.com&password=123, instead of server address http://localhost:4003/api/authenticate

can you help me ?

Here is my popup.html:

 <form id="mainForm" class="" novalidate>
      <div class="login">
        <div class="loginrow"><label>Email:</label></div>
        <div class="loginrow"><input type="email" id="email" name="email" value="elshad" /></div>
        <div class="loginrow"><label>Password:</label></div>
        <div class="loginrow"><input type="password" id="password" name="password" value="pass" /></div>
        <div class="loginrow">
          <input id="logmein" type="submit" value="Login"/>
          <button id="signmeup">SignUp</button>
          <button id="forgot">Problems?</button>
        </div>
     </div>
</form>

This is code in popup.js:

logmein.addEventListener("click", async () => {
   
  console.log("Clicked");

    // In your JS :
    form = document.getElementById("mainForm");

    form.submit(function( event ) {
      event.preventDefault();
      const formData = new URLSearchParams(new FormData(this));
      fetch("http://localhost:4003/api/authenticate",
        {   method: 'POST',
            headers: { "Accept": "application/json", "Content-Type": "application/json; charset=utf-8" },
            //mode : 'same-origin',
            mode: "no-cors",
            credentials: 'same-origin' ,
            body : formData
        })
        .then(function(response) {
          return response.text()
        }).then(function(text) {
            //text is the server's response
        });
    });

  });
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!