'Error: ENOENT: no such file or directory, open './node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false'
I'm trying to make a JWT auth with laravel on my back and react-native (with expo) on my front. I have already set up my endpoint to get my token and is working properly.
It says that a file is not accessible but I don't understand what is that file for and why it has an IP inside the route.
I'm getting this issue:
ENOENT ERROR My code is:
imports...
const baseUrl = 'http://192.168.1.163:8000';
const SignInScreen = ({ navigation }) => {
const [data, setData] = React.useState({
username: '',
password: '',
check_textInputChange: false,
secureTextEntry: true,
isValidUser: true,
isValidPassword: true,
});
const { signIn } = React.useContext(AuthContext);
const textInputChange = (val) => {
if (val.trim().length >= 4) {
setData({
...data,
username: val,
check_textInputChange: true,
isValidUser: true
});
} else {
setData({
...data,
username: val,
check_textInputChange: false,
isValidUser: false
});
}
}
const handlePasswordChange = (val) => {
if (val.trim().length >= 8) {
setData({
...data,
password: val,
isValidPassword: true
});
} else {
setData({
...data,
password: val,
isValidPassword: false
});
}
};
const updateSecureTextEntry = () => {
setData({
...data,
secureTextEntry: !data.secureTextEntry
})
};
const loginHandle = async (username, password) => {
var token;
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
grant_type: "password",
client_id: "1",
client_secret: "blabla",
username: username,
password: password,
scope: "*"
})
};
fetch(`${baseUrl}/oauth/token/`, requestOptions)
.then((response) => {
console.log(response);
response.json().then((data) => {
token = data.access_token;
});
});
if (token == 'undefined') {
Alert.alert('Invalid user', 'El usuario no existe, o la contraseña o usuario son incorrectas ¿Estás seguro de que tienes cuenta?',
[
{ text: 'Okey' }
]);
}
else {
signIn(username, password, token);
}
signIn(username, password);
}
return (
Some html code that runs loginhandle
);
};
export default SignInScreen;
Solution 1:[1]
The reason why you are getting this error is because you are logging the raw response:
console.log(response)
You need to first use the json()
and afterwards you can console.log
that result.
Took me a while to figure that out!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mr.B |