[Vuejs]-Firebase POST custom ID

2👍

Make sure to use the put instead of the post request else you’ll end up with the auto generated id inside of your “user_one”

POST will give you:

{
  "users": {
    "user_one": {
      "134134hnj34nuj134bn": {
        "username": "jdoe",
        "password": "123"
      }
    }
  }
}

axios.put('https://projectname.firebaseio.com/padres/user_one.json', padre)

PUT will give you what you want.

{
  "users": {
    "user_one": {
      "username": "jdoe",
      "password": "123"
    }
  }
}
👤Bram G

0👍

There sure is. Just use the HTTP PUT method and specify the entire path. Depending on your library it may be as simple as:

axios.post('https://projectname.firebaseio.com/padres/user_one.json', padre)

For more, see the Firebase REST API documentation on the PUT command.

0👍

If you are using Php cURL, i had achieved this with PUT by adding my custom ID in url.

Leave a comment