I am in the process of familiarizing myself with react native and attempting to communicate with an API helper that I have implemented within one of my screen files. While I suspect there may be a syntax error causing issues, I also wonder about the overall architecture of the setup given my background in iOS development.
Here is the function where the error occurs:
handleLoginPress = () => {
ApiHelper.loginDriver(this.state.email, this.state.password)
.then((result) => {
console.log(result);
}).catch((error) => {
console.log("error is " + error);
});
};
The encountered error reads as follows:
Property 'then' does not exist on type 'void'
This presents the function being called:
static loginDriver(username: string, password: string) {
fetch('http://localhost:8080/drivers/login', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
uername: username,
password: password,
}),
});
}
My assumption leads me to believe that there might be a need for specifying the return type within the API's login function?