Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React native post using typescript and axios not working

$
0
0

I need a bit of help with my react native in typescript project. I am having an issue posting data with Axiospost executed with axios call is failingHere my code below

import { LOGIN_URL, showErrorAlert } from "../../utils/constants"import axios, {AxiosResponse} from "axios"import { APIUser } from "../../utils/interfaces" const [userApiData, setUserApiData] = useState<APIUser[]>([]);    let tokenValue    const onLogin = () => {      console.log("<<< inside onlogin >>>>>")      const dataToSend = {        email: email,        password: password,      }      console.log("<<< dataToSend >>>>>", dataToSend)      console.log("<<< LOGIN_URL >>>>>", LOGIN_URL)      axios        .post<APIUser[]>(LOGIN_URL, dataToSend)        .then((response:AxiosResponse) => {          console.log("inside promise")          console.log('response ', response)        })        .catch((err) => {          console.log("inside error")          console.log(err)          throw err        })    }Heres my interface    export interface APIUser {        success: boolean,        message: null,        data: UserData    }    export interface UserData  {        userId: string,        organisationId: string,        email: string,        firstname: string,        lastName: string,        userToken: string,        refreshToken: string    }

console.log(response) returns nothingKindly assist me in helping me find out why this is not returning any response


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>