0

I want to pass parameter in POST request in Axios library as :

{
  params : 
  {
            email: email,
            password: password,
  }
}

I have tried :

axios.post(url, 
            { 
                params : {
                    email: '[email protected]',
                    password: 'Password!',
                    sign_in_type: '1',
                    fb_token: '',
                    google_token: ''
                }
            }, 
            {headers: headers}
        )

But nothing works! Please suggest if you have any idea.

Thank you!

1 Answer 1

1
 const getData = async () => {
        const params = {
          params: {
              email: '[email protected]',
              .....
          }
        };
    try {
        const { data } = await axios({
            method: 'post', 
            url: `your url`,
            data: params,
            headers: {
             'token': token
           }
        });
     console.log(data);
    } catch(e) {
     console.log(e);
    }
 }
Sign up to request clarification or add additional context in comments.

4 Comments

In this how i will get response? means .then method ?
in the data variable, You can use try and catch block if you want to handle errors, let me update my answer to show you more
@Samad one more thing actually i am new to this so.. do i need to do anything with getData? and data orinting in log is response?
i just have made a function named getData which you could call from somewhere

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.