How to send request with javascript on spring boot MVC application that uses form authentication?

When I sign in my web app I could send request from browser, but when I want to call it with javasctipt (fetch/ajax request) it always give me status code 302, i think it is redirecting me on login page. I tried to set authorization header with Basic authentication but it won’t work. Is there a way to perform call with javascript if i have form authentication?

This is from my web.xml file:

  <login-config>
        <auth-method>FORM</auth-method>
        <form-login-config>
            <form-login-page>/login</form-login-page>
            <form-error-page>/login</form-error-page>
        </form-login-config>
  </login-config>

This is my controller:

@Controller
@RequestMapping("/user")
public class UserController {
    @ResponseBody
    @RequestMapping(path = "get-user", method = RequestMethod.GET)
    public User GetUser(HttpServletRequest request, @RequestParam("userCn") String userCn)
    {
        User k = PomEJB.getInstance().findKorisnik(userCn);
        return k;
    }
}