I am sending an ajax call to the server to sign up the user
    $.ajax({
    url: `${baseUrl}/users`,
    type: 'POST',
    data: data,
    success: function(data) {
       console.log(data);
       $('#signUpModal').modal('hide');         
    },
    error: function(e) {
        console.log(e);
    }
});
Server side(snipet):
        user.save().then(()=>{
        return user.generateAuthToken();
    }).then((token)=>{
        res.header('x-auth', token).send(user);
    }).catch((e)=>{
        res.status(400).send(e)
    });
The code does save user to the database, but doesn't set the header.
Note:It sets the header when i am using Postman, so it must be the ajax call that causes the problem? Note2:it works if i send the data without jQuery. (with good old plain form), but i am curios about the solution so i won't delete my question.
Thank you in advance for your help.

