Response is always returning undefined. I'm calling simple log in service using #apisauce in my react native app. Here's my implementation.
This is the handleSubmit method.
import loginApi from '../api/loginApi';
const handleSubmit = async ({email, password}) => {
const result = await loginApi.login(email, password);
console.log(result);
console.log(result.data);
};
Here is the Api call
import {create} from 'apisauce';
const apiClient = create({
method: 'POST',
baseURL: 'https://...',
timeout: 10000,
});
export default apiClient;
And here's the api layer for login.
import apiClient from './client';
const login = async (email, password) => {
return await apiClient.post('/login', {email, password});
};
export default {login};
result always remains undefined. No error, no exceptions, nothing is coming in the result. I've checked the URLs, prams etc on #postman a number of times and everything is alright.
CodePudding user response:
Result reamins undefined, because you're not returning anything from your loginApi.login() function :)