This is my first post so apologies if the format is wrong or I'm missing info or something!
I'm unable to connect to an API running on localhost through an Android emulator, or on a physical iPhone using React Native.
I've tried to change the localhost in my fetch request so it now looks as follows:
https://MYIPADDRESS:44357/api/user/login
This is the error I get when trying to fetch the API
TypeError: Network request failed
- node_modules\react-native\Libraries\LogBox\LogBox.js:148:8 in registerError
- node_modules\react-native\Libraries\LogBox\LogBox.js:59:8 in errorImpl
- node_modules\react-native\Libraries\LogBox\LogBox.js:33:4 in console.error
- node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
- node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException
- node_modules\react-native\Libraries\Core\ExceptionsManager.js:171:19 in handleException
- node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
- node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:9:32 in ErrorUtils.setGlobalHandler$argument_0
- node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch
- node_modules\regenerator-runtime\runtime.js:293:29 in invoke
- node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch
- node_modules\regenerator-runtime\runtime.js:154:27 in invoke
- node_modules\regenerator-runtime\runtime.js:164:18 in PromiseImpl.resolve.then$argument_0
- node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
- node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in _callImmediatesPass
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:441:30 in callImmediates
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:387:6 in __callImmediates
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in __guard$argument_0
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:4 in flushedQueue
* [native code]:null in flushedQueue
* [native code]:null in invokeCallbackAndReturnFlushedQueue
fetch('https://IPADDRESS:44357/api/user/login', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
user: this.state.username,
password: this.state.password,
})
})
I hope someone can help! :) Thanks in advance.
On Android Emulator, you should use http://127.0.0.1:44357.
On iOS Simulator, you should use http://10.0.2.2:44357.
On real devices, you should open 44357 port and use http://YOURIPADDRESS:44357.
Related
I'm setting up React Native and downloaded Expo Go but when I open the app this message pops up and I'm not able to continue working.
Edit: Using a Windows computer on Windows 10 and iPhone 11 for Expo Go
TypeError: now is not a function. (In 'now()', 'now' is undefined)
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:95:4 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:141:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules\#react-native\polyfills\error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:370:8 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:113:4 in callFunctionReturnFlushedQueue
I want to generate seed phrase in react native using react-native-bip39.
But I have some problems using this module.
//
import bip39 from 'react-native-bip39'
const seed = async () => {
const seeds = await bip39.generateMnemonic(256)
console.log(seed)
}
//
After compile this I can see these errors below
[12:33:09] TypeError: null is not an object (evaluating 'RNRandomBytes.seed')
at node_modules\react-native\Libraries\LogBox\LogBox.js:149:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:172:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules#react-native\polyfills\error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules\metro-runtime\src\polyfills\require.js:204:6 in guardedLoadModule
at ``http://192.168.112.84:19000/node_modules\expo\AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:282809:3`` in global code
[12:33:09] Invariant Violation: "main" has not been registered. This can happen if:
Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
A module failed to load due to an error and AppRegistry.registerComponent wasn't called.
at node_modules\react-native\Libraries\LogBox\LogBox.js:149:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:172:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules#react-native\polyfills\error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:367:8 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:4 in callFunctionReturnFlushedQueue
I tried to generate seed phrase but it doesn't work actually
problem to connect the application to the backend.
I use React Native with EXPO
The error occurs on a login screen when trying to validate a user on a DB in the sql-server
I believe the error is in this: async function sendForm () {
let response = await fetch ('http://myip:3000/login'
however, I don't know what could be wrong ... suddenly some Node module is missing.
1 - already redone the project
2 - deleted node_modules and yarn install to remake
3 - already test the Controller.js routes and they are working.
4 - images: https://ibb.co/B354qky https://ibb.co/ZRjKRnn https://ibb.co/pyDyM70
THIS IS THE ERROR:
[Unhandled promise rejection: SyntaxError: JSON Parse error: Unrecognized token '<']
at [native code]:null in parse
at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in _callImmediatesPass
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:441:30 in callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:387:6 in __callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guardat node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:4 in flushedQueue
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue
I am using react native and expo 4.4.4 and
"react-native-material-dropdown": "^0.11.1",
This library was picked from this Npm link and Github Link
Just copy pasted the example usage code you have given...
Its showing below error :
TypeError: undefined is not an object (evaluating '_reactNative.Animated.Text.propTypes.style')
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue
I don't think react-native-material-dropdown is supported in Expo.
Use #react-native-community/picker instead.
Warning: Failed prop type: Invalid prop Component supplied to PadView.
Hi, I am new to react-native, the red message just keep showing up, but everything looks fine, and the app rendered out correctly, but the red message just keeps showing up in the terminal, do you guys have any idea what doesn't that mean, thanks for the help.
Warning: Failed prop type: Invalid prop `Component` supplied to `PadView`.
- node_modules\react-native\Libraries\YellowBox\YellowBox.js:63:8 in console.error
- node_modules\expo\build\environment\muteWarnings.fx.js:27:24 in error
- node_modules\prop-types\checkPropTypes.js:20:20 in printWarning
- node_modules\prop-types\checkPropTypes.js:83:12 in checkPropTypes
- node_modules\react\cjs\react.development.js:1796:19 in validatePropTypes
- node_modules\react\cjs\react.development.js:1969:22 in createElementWithValidation
- node_modules\react-native-elements\src\list\ListItem.js:101:4 in ListItem
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:10696:27 in renderWithHooks
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:13481:6 in mountIndeterminateComponent
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:20459:25 in beginWork$$1
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19370:24 in performUnitOfWork
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19347:39 in workLoopSync
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18997:22 in renderRoot
* [native code]:null in renderRoot
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18709:28 in runRootCallback
* [native code]:null in runRootCallback
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5642:32 in runWithPriority$argument_1
- node_modules\scheduler\cjs\scheduler.development.js:643:23 in unstable_runWithPriority
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5638:22 in flushSyncCallbackQueueImpl
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5627:28 in flushSyncCallbackQueue
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18556:30 in scheduleUpdateOnFiber
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:21822:15 in scheduleRootUpdate
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:23042:20 in ReactNativeRenderer.render
- node_modules\react-native\Libraries\ReactNative\renderApplication.js:52:52 in renderApplication
- node_modules\react-native\Libraries\ReactNative\AppRegistry.js:116:10 in runnables.appKey.run
- node_modules\react-native\Libraries\ReactNative\AppRegistry.js:197:26 in runApplication
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0
* [native code]:null in callFunctionReturnFlushedQueue
Update react-native-elements. Issue was fixed in version 1.2.2 (was caused by some changes in propTypes treatment in React Native 0.61.1 I believe).