ckatzorke / howlongtobeat

A simple api for https://howlongtobeat.com/
Do What The F*ck You Want To Public License
338 stars 45 forks source link

Ported Deprecated Request Lib to Axios #24

Closed bedwardly-down closed 3 years ago

bedwardly-down commented 3 years ago

The request library is no longer being maintained and one of the projects I use daily only pulled in request from your library. Axios is a very heavily active http library that is considered a pretty decent drop in replacement for it.

This is a straight port using the same overall style as your original code down to spacing and whatnot but there were some minor changes made during the conversion. They are as follows:

1) The form parameter in the original code was removed from its section and converted into a URLSearchParams object as per required for the new post call: https://github.com/axios/axios#using-applicationx-www-form-urlencoded-format

2) The callbacks used originally were replaced due to axios not handling errors and responses the exact same way. Luckily, it had comparable replacements. I opted for a Try Catch system for handling them since it was a bit more easily readable than what the official docs recommended and I felt that it kept the spirit of the original implementation.

ckatzorke commented 3 years ago

Thank you - this was long overdue. I will check the branch and merge it eventually

bedwardly-down commented 3 years ago

Thanks for merging it. :D