'502 Bad Gateway Error to connect React Native to NodeJS

I'm developing a project using Expo with React Native, Axios, NodeJS and MongoDB and I have a problem to Signup an user.

After entering the data to Signup, it returns me 502 Bad Gateway Error.

This is the error:

Request failed with status code 502
at http://gf-wi5.anonymous.logisticsmanagement.exp.direct/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:142801:25 in createError
at node_modules\axios\lib\adapters\xhr.js:159:17 in setRequestHeader
at node_modules\axios\lib\adapters\xhr.js:7:4 in <global>
at node_modules\event-target-shim\dist\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent
at node_modules\react-native\Libraries\Network\XMLHttpRequest.js:614:6 in setReadyState
at node_modules\react-native\Libraries\Network\XMLHttpRequest.js:396:6 in __didCompleteResponse
at node_modules\react-native\Libraries\vendor\emitter\_EventEmitter.js:135:10 in EventEmitter#emit
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:414:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:113:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:4 in callFunctionReturnFlushedQueue

After debug tests, I noticed that what is preventing it is in the Response Schema.

This is the function where the error is found and identified:

const handleRegister = (credentials, setSubmitting) => {
        handleMessage(null);
        const url = "https://logisticsmanagementcoficab.herokuapp.com/users/register";
        axios.post(url, credentials)



        // ERROR -->
        .then((response) => { 
            const { message, status } = console.log(response.data); 
            if (status !== 'SUCCESS') {
                handleMessage(message, status);
            } else {
                navigation.navigate("Login");
            }
            setSubmitting(false);
        })
        // <-- ERROR



        .catch((err) => {
            console.log(err);
            setSubmitting(false);
            handleMessage('Make sure you are connected to the network');
        });
};


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source