just1and0 / object-to-array-convert

🏠ℹ️ This package making it very easy to convert object to array and manipulate it
https://just1and0.github.io/object-to-array-convert/
MIT License
6 stars 2 forks source link

Got an error when using this package. #5

Open VinceSanityyy opened 4 years ago

VinceSanityyy commented 4 years ago

Hello, I am using this package but i cannot proceed because there is an error. TypeError: data.val is not a function

here is the stack trace

 3 |  O2A: function(data){
  4 | const converted = []
  5 | //LOOPING EACH CHILD AND PUSHING TO ARRAY
> 6 |       for (const [key, value] of Object.entries(data.val())) {
    | ^  7 |                 value['object_key'] = key;
  8 |                 converted.push(value);
  9 |        } 

What i did is

  const [doctors, setDoctor] = React.useState([]);

  useIonViewDidEnter(()=>{
    console.log('Enter')
    firebase.database().ref('users').orderByChild('type').equalTo('doctor').on('value',(snapshot)=>{
          // console.log(snapshot.val())
          setDoctor(snapshot.val())
          // event.detail.complete()
        })
  })

I am using Ionic + React.

pailoro commented 4 years ago

Dont work for me too, on Angular