danieltanfh95 / btapi

baka tsuki api clean up
http://btapi-shadowys.rhcloud.com/
8 stars 5 forks source link

Light novel list not working (Cannot read property '0' of undefined) #22

Closed AzSiAz closed 8 years ago

AzSiAz commented 8 years ago

Seem like light novel list is broken with the last commit tried with the one from august to be sure and it still work

complete error : `/btapi/routes/api.js:197 titledata.lastreviseddate=serieslist[key].revisions[0].timestamp; ^

TypeError: Cannot read property '0' of undefined at /Users/Stef/Documents/Workspace/app/btapi/routes/api.js:197:60 at IncomingMessage. (/Users/Stef/Documents/Workspace/app/btapi/routes/api.js:548:7) at emitNone (events.js:72:20) at IncomingMessage.emit (events.js:166:7) at endReadableNT (_stream_readable.js:893:12) at doNTCallback2 (node.js:429:9) at process._tickCallback (node.js:343:17)`

danieltanfh95 commented 8 years ago

Apparently there's a problem with the media wiki parse. I reversed the order of the params and it worked again.

AzSiAz commented 8 years ago

Thanks but api/category?type=LIGHT_NOVEL&language=english still don't seem to work. So I searched and I think you forget line 187 and 66, you need to replace %7C by |, it seem to solve the problem, probably because you use encodeURI and %7C is reencoded

danieltanfh95 commented 8 years ago

Thanks, I missed those while I was refactoring. The API should work now.

AzSiAz commented 8 years ago

You're welcome :)

AzSiAz commented 8 years ago

Maybe another problem "titles":{"1759":{"page":"Kara_no_Kyoukai","title":"Kara no Kyoukai","lastreviseddate":"2015-04-28T17:40:11Z","lastrevisedid":440032,"pageid":1759},"1838":{"page":"Zero_no_Tsukaima","title":"Zero no Tsukaima","lastreviseddate":"2015-09-29T11:51:43Z","lastrevisedid":464468,"pageid":1838} Before I was taking novel list directly inside titles and not inside title.XXXX (where XXXX seem to be the same as pageid every time), if it's intended that's not really a problem but prefer to ask just to be sur before refactoring my code^^

danieltanfh95 commented 8 years ago

Yeah, the "title" key is inside the "titles" json. It keeps the call more consistent, I guess.

AzSiAz commented 8 years ago

Not what I mean is before it was something like that : {"titles":[{"page":"Kara_no_Kyoukai","title":"Kara no Kyoukai","lastreviseddate":"2015-04-28T17:40:11Z","lastrevisedid":440032,"pageid":1759},{"page":"Zero_no_Tsukaima","title":"Zero no Tsukaima","lastreviseddate":"2015-09-29T11:51:43Z","lastrevisedid":464468,"pageid":1838}]} And now it's : "titles":{"1759":{"page":"Kara_no_Kyoukai","title":"Kara no Kyoukai","lastreviseddate":"2015-04-28T17:40:11Z","lastrevisedid":440032,"pageid":1759},"1838":{"page":"Zero_no_Tsukaima","title":"Zero no Tsukaima","lastreviseddate":"2015-09-29T11:51:43Z","lastrevisedid":464468,"pageid":1838}

To be more specific titles":{"1759":{...} was just {"titles":[{...},{}]

danieltanfh95 commented 8 years ago

I've corrected that (The changes are now online). It is supposed to look like the one before.

AzSiAz commented 8 years ago

Sorry still no and series.html & category.html don't work anymore

danieltanfh95 commented 8 years ago

I've uploaded the latest version. Apparently heroku fails if I use static files instead :confused: The routes have been reverted to : https://baka-tsuki-api.herokuapp.com/series (Note however, I'm still dealing with the static issue, so the JSON won't render properly yet on the docs.) Update : Apparently heroku have not registered the static files. It's working now. Update : The current version you're seeing on https://baka-tsuki-api.herokuapp.com/api/time?updates=20 is the final version of the API. I don't think it will changed until version 2.0 is decided.

I'm getting this JSON for the api route, /api/time?updates=1

[
  {
    "title": "High school DxD Tom 19 - Scisle tajne",
    "pageid": 78958,
    "timestamp": "2015-09-30T12:26:48Z",
    "revid": 464618
  }
]
AzSiAz commented 8 years ago

yeah on my server it's working again like before too Yep same with a s for update but that it

danieltanfh95 commented 8 years ago

Update : Apparently heroku have not registered the static files. It's working now. Update : The current version you're seeing on https://baka-tsuki-api.herokuapp.com/api/time?updates=20 is the final version of the API. I don't think it will changed until version 2.0 is decided.

AzSiAz commented 8 years ago

Good to know it won't change before some time, I'm using it to build a push server and I don't plan to refactor it for now x)

danieltanfh95 commented 8 years ago

Alright. Btw, would that push server happen to live in your repo? :laughing:

AzSiAz commented 8 years ago

Unfortunately not for now, it's written in typescript, using onesignal and highly experimental, because I never touch nodeJS before and to be honest I'm not sur It's completely working x). Well I can try to clean up my code a little and upload it, check in the next hour it should be in my repo list

danieltanfh95 commented 8 years ago

Noted. Thanks