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:
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.
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.