loumadev / EdupageAPI

Simple node.js package to manage your EduPage account.
GNU General Public License v3.0
27 stars 2 forks source link

`const d = this.period.startTime.split(":");` can't read `startTime` of `undefined` #10

Closed 0Charliecat closed 2 years ago

0Charliecat commented 2 years ago

Hi! sorry me again, got a roadblock today when listing lessons, idk what Edupage outputs there

/CON/edupage-ical/node_modules/edupage-api/src/Lesson.js:130
                const d = this.period.startTime.split(":");
                                      ^

TypeError: Cannot read properties of undefined (reading 'startTime')
    at Lesson.init (/CON/edupage-ical/node_modules/edupage-api/src/Lesson.js:130:25)
    at new Lesson (/CON/edupage-ical/node_modules/edupage-api/src/Lesson.js:108:42)
    at /CON/edupage-ical/node_modules/edupage-api/src/Timetable.js:57:78
    at Array.map (<anonymous>)
    at Timetable.init (/CON/edupage-ical/node_modules/edupage-api/src/Timetable.js:57:66)
    at /CON/edupage-ical/node_modules/edupage-api/src/Edupage.js:359:34
    at Array.forEach (<anonymous>)
    at Edupage._updateInternalValues (/CON/edupage-ical/node_modules/edupage-api/src/Edupage.js:359:19)
    at Edupage.refresh (/CON/edupage-ical/node_modules/edupage-api/src/Edupage.js:194:8)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I'm using snippet of your code in https://github.com/loumadev/EdupageAPI#get-lessons-for-a-given-date

I hope I didn't disturb you.

loumadev commented 2 years ago

Hello, no, It's OK, it's kinda my responsibility to keep this library stable and functional.

I tested the example, and it's working fine for me, so I assume there were no changes made by Edupage, however there must be something what differs from my setup. The problem is, that the library cannot find certain period. I can't tell what the issue is so far, so I released a new version and added some error handling (v0.7.13). Please, update your current EdupageAPI version and run the example again. It should now generate some error message. Post it here, as well as an error log, so I can see what's going on. In case, we wouldn't be able to fix this issue (I believe we will), you could then just toggle the flag to hide the warnings and continue to use it as usual, since it's not really a fatal error.

I hope I've mentioned everything. I'm currently sick, and my abilities are slightly limited, so please take that into account.

0Charliecat commented 2 years ago

kinda works right now, sometimes (like 5% of the time it just hangs in there) but it returns data now yey

loumadev commented 2 years ago

I forgot to mention that I have also fixed some random bug which I encountered while looking for the lines in your error. There was just missing parameter in a function call, like literally new Timetable(var1, var2, ). I honestly don't know what happened there lol. I tested it with and without the parameter, but the result was nearly the same, and no errors were pop up. You can post here the error logs anyway, so I could try to fix it. It shouldn't be so unstable like "there's some chance it won't work".

0Charliecat commented 2 years ago

works perfectly now, no problem for me lately