I want to send data to my sever but I got this error:

TypeError: Failed to fetch

[![enter image description here](https://i.stack.imgur.com/ScagK.png)](https://i.stack.imgur.com/ScagK.png)

my codes:

```
function login(username, password) {
    const requestOptions = {
        method: 'POST',
        headers: { 'Content-Type': 'application/json','charset':'utf-8' },
        body: JSON.stringify({ 'username':username , 'password':password })
    };

    console.log(requestOptions);

    return fetch(BASE_URL+serverConstants.LOGIN_POST_REQUEST, requestOptions)
        .then(response => {
            if (!response.ok) {
                return Promise.reject(response.statusText);
            }

            return response.json();
        })
        .then(user => {
            // login successful if there's a jwt token in the response
            if (user && user.token) {
                // store user details and jwt token in local storage to keep user logged in between page refreshes
                localStorage.setItem('user', JSON.stringify(user));
            }

            return user;
        });
}

```

but I tested it on postman I got correct response.

[![enter image description here](https://i.stack.imgur.com/LtsVb.png)](https://i.stack.imgur.com/LtsVb.png)