Axios is returning undefined

My API is returning proper data when I am requesting from Postman. Even API is getting properly called from React, I checked using console.log inside the controller, but I am always getting undefined response. I am not sure what the mistake is.

const submit = async (e: SyntheticEvent) => {

    const response = await axios
        .get('certificates', {
            params: { sponser },
        .then((res) => {
            console.log(response); //undefined
            alert(res.status);  //200
            alert(res); //[object Object]

Could you please help me on the same.

Source: React – Stack Overflow

November 18, 2021
Category : News
Tags: axios | HTTP | nestjs | node.js | reactjs

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.