Fillah Firdausyah
Fillah Firdausyah

Reputation: 87

get specific data from Firebase REST API

I'm learning about reactJS and for the database I'm using firebase realtime Database.. everything works. but there is one problem..

i have Firebase url like this

https://my-app-name-rtdb.asia-southeast1.firebasedatabase.app/data.json

and the result when get the data

{
  "data" : {
    "-Mc8l24sBroFw8JoA32e" : {
      "data" : {
        "authorized" : {...},
        "authorizedFinance" : {...},
        "authorizedTechnical" : {...},
        "billingAddress" : {...},
        "information" : {...},
        "serviceOrder" : {...},
        "subscriptionFee" : {...},
        "typeofOrder" : {...}
      }
    },
    "-Mc9XCIdCg4FLDzj3Xmg" : {
      "data" : {
        "authorized" : {...},
        "authorizedFinance" : {...},
        "authorizedTechnical" : {...},
        "billingAddress" : {...},
        "information" : {...},
        "serviceOrder" : {...},
        "subscriptionFee" : {...},
        "typeofOrder" : {...}
      }
    }
  }
}

what i want is,just get 1 data by the id -Mc8l24sBroFw8JoA32e.

{
  "data" : {
    "-Mc8l24sBroFw8JoA32e" : {
      "data" : {
        "authorized" : {...},
        "authorizedFinance" : {...},
        "authorizedTechnical" : {...},
        "billingAddress" : {...},
        "information" : {...},
        "serviceOrder" : {...},
        "subscriptionFee" : {...},
        "typeofOrder" : {...}
      }
    }
 }

fireabse

i have tried to pass params in the url like this

https://my-app-name-rtdb.asia-southeast1.firebasedatabase.app/data.json?id=-Mc8l24sBroFw8JoA32e

but is not working. i get the all data..

so, how to do it? is it possible?

Upvotes: 1

Views: 989

Answers (2)

p2pdops
p2pdops

Reputation: 515

Hi you can navigate through the child nodes in the Realtime Database console by clicking on nodes

It provides a URL for the node you want to access and append .json at last to access it. Make sure your rules and authentication are synced.

So required link would be :

https://my-app-name-rtdb.asia-southeast1.firebaseio.com/data/-Mc8l24sBroFw8JoA32e.json

Ref:

enter image description here

Realtime database - nodes navigation to get link

Hope this helps🤝

Upvotes: 2

Frank van Puffelen
Frank van Puffelen

Reputation: 598718

The correct URL to get just that specific key is:

https://my-app-name-rtdb.asia-southeast1.firebasedatabase.app/data/-Mc8l24sBroFw8JoA32e.json

So the .json is last, and before that you have the entire path to the data that you want to retrieve.

Upvotes: 2

Related Questions