Promise reject as json
<p>I'm working on a project in react-native with laravel (php) backend. I have a class 'AuthService' with method login (username,password)  which returns a promoise, resolving the user and rejecting the errors. The errors will be responded in JSON, so that I can show the particular errors to the user, but since unexpected errors can occur, I also want to provide a json object to consuming component. </p>

<pre><code>        return fetch(Config.AUTH_URL, {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({
            email: email, //provided
            password: password //provided
        })
    })
        .then(response=&gt; {
            if (response.ok) {
                return response.json().then(user=&gt; {
                    console.log(user);
                    AsyncStorage.setItem('auth.token', user.api_token);
                    AsyncStorage.setItem('user_name', user.user.name);
                    AsyncStorage.setItem('user_email', user.user.email);
                })
            } else {
                if (response.status == 422) {
                    //this needs to be rejected, but gives error
                    return Response.reject(response.json());

                } else {
                //when the response from server is unexpected error (eg. 500 without json data),I still want to reject with a json object
                    return Promise(null, ()=&gt; {
                        return {"email": ["Technical problem, try later"]}
                    });
                }
            }
        }, err=&gt; {
             throw Error({"email": ["Technische fout. Probeer het opnieuw"]});
        });
</code></pre>