0
votes

I am not able to just fetch the status code from a restful webservice. The web service is just responding with 201 or 401. I am pretty new to react native and I just stuck for hours now.

I am calling the this function in another component. The response I am receiving is always LOG {"_40": 0, "_55": null, "_65": 0, "_72": null}

export default class forgotPasswordCall extends Component {
    _forgotPassword = async (username, email) => {
        let bodyData = {
            'username': username,
            'email': email,
        }
        try {
            const response = await fetch('webserviceURL', {
                method: "POST",
                headers: {
                    'Content-Type': 'application/json',
                    Accept: 'application/json',

                },
                body: JSON.stringify(bodyData)
            })
            return response.status;
        }
        catch (error) {
            console.error(error);
        }


    }


}

I would need to receive the status code itself.

1
Hi, I saw this before. But I don't want to fetch the body. The webserver is just return the status code nothing elseSylber

1 Answers

0
votes

I would highly recommend using axios instead of fetch. You should try it !