# How can I make a post request to API after a user signs up?

**URL:** <https://community.auth0.com/t/how-can-i-make-a-post-request-to-api-after-a-user-signs-up/121482>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [November 22, 2023, 9:39pm UTC](https://community.auth0.com/t/how-can-i-make-a-post-request-to-api-after-a-user-signs-up/121482 "2023-11-22T21:39:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![FreshPineapples](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/freshpineapples/32/51958_2.png) [@FreshPineapples](https://community.auth0.com/u/FreshPineapples)\
**Post date:** [November 22, 2023, 9:39pm UTC](https://community.auth0.com/t/how-can-i-make-a-post-request-to-api-after-a-user-signs-up/121482/1 "2023-11-22T21:39:30Z")

</div>

Hello. I’m currently working a MERN app that uses Auth0 for user authentication. Currently I’m implementing the database user functionality. I want to make an axios post request to my backend API every time a user signs up with Auth0. I wanted to ask what the best way to implement this was?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 22, 2023, 10:19pm UTC](https://community.auth0.com/t/how-can-i-make-a-post-request-to-api-after-a-user-signs-up/121482/3 "2023-11-22T22:19:34Z")

</div>

Hi @FreshPineapples,

I suggest using a Post-User Registration Action to make an Axios request to your backend API. Below is an example:

```auto
exports.onExecutePostUserRegistration = async (event, api) => {
  const axios = require('axios');
  
  const url = 'https://YOUR_URL';
  const options = {
    headers: {
      'Content-Type': 'application/json'
    }
  };
  const data = {
    username: event.user.username, 
    email: event.user.email
  };
  var response = await axios.post(url, data, options);
  console.log(response.data);
};

```

See the following resources for more details:

- [Post User Registration Flow](https://auth0.com/docs/customize/actions/flows-and-triggers/post-user-registration-flow)
- [Post User Registration Event Object](https://auth0.com/docs/customize/actions/flows-and-triggers/post-user-registration-flow/event-object)

Let me know if you have any questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![FreshPineapples](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/freshpineapples/32/51958_2.png) [@FreshPineapples](https://community.auth0.com/u/FreshPineapples)\
**Post date:** [November 23, 2023, 12:23am UTC](https://community.auth0.com/t/how-can-i-make-a-post-request-to-api-after-a-user-signs-up/121482/4 "2023-11-23T00:23:48Z")

</div>

Hi, I’ve tried using this before although I’m not sure if I’m doing everything correctly. I setup my Auth0 Action in the following way. I also integrated this action into the Post User Registration flow on my Auth0 dashboard.

```auto
exports.onExecutePostUserRegistration = async (event, api) => {
  const axios = require('axios');
  
  const url = 'http://localhost:3001/api/users';
  const options = {
    headers: {
      'Content-Type': 'application/json'
    }
  };
  const data = {
    username: event.user.user_id, 
  };
  var response = await axios.post(url, data, options);
  console.log(response.data);
};

```

This should send a post request to my backend api which then uploads the user id into the database. However, the database does not update. The database and backend server are working because when I test it on Postman it works appropriately. Please let me know if I’m implementing something wrong or I’m missing something. Thanks!

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 28, 2023, 7:23pm UTC](https://community.auth0.com/t/how-can-i-make-a-post-request-to-api-after-a-user-signs-up/121482/5 "2023-11-28T19:23:20Z")

</div>

Hi @FreshPineapples,

Your implementation looks good to me.

Are you still experiencing any errors? If so, could you provide details around what you are experiencing?

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 12, 2023, 7:23pm UTC](https://community.auth0.com/t/how-can-i-make-a-post-request-to-api-after-a-user-signs-up/121482/6 "2023-12-12T19:23:58Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
