bitovians / pto

PTO Policy + Freshbooks integration
https://bitovians.github.io/pto/
0 stars 1 forks source link

TypeError: r.response.time_entries.time_entry.forEach is not a function #8

Closed chasenlehara closed 5 years ago

chasenlehara commented 5 years ago

Here’s where the exception is thrown: https://github.com/mjstahl/pto-tracker/blob/d2c733d31936ec2b1952e613348b41bc4fb34d57/models/time-entries.js#L31

Steps to reproduce (for me):

  1. Clone the repo
  2. npm i && npm run develop
  3. Go to http://localhost:8080/
  4. Enter my auth token
  5. Click Authenticate

Here’s what r.response.time_entries.time_entry looks like when the exception is thrown:

{  
  "time_entry_id": {  
    "_text":"1481692"
  },
  "staff_id" :{  
    "_text":"35661"
  },
  "project_id": {  
    "_text":"9"
  },
  "task_id": {  
    "_text":"48"
  },
  "hours": {  
    "_text":"8"
  },
  "date": {  
    "_text":"2015-06-19"
  },
  "notes": {
  },
  "billed": {  
    "_text":"0"
  }
}

Let me know if there’s any other info I can provide. This project looks awesome!

mjstahl commented 5 years ago

I see what the problem could be here. xml-js doesn't know that the XML could have 1 or more time_entry. So when it sees one it's an object, when it sees more than 1 it's an array.

Thank you for this.