lingua-libre / SignIt

🌻 Lingua Libre SignIt web-browser extension translates selected word in French Sign Language via an elegant pop up so you learn sign language while reading online.
https://addons.mozilla.org/en-US/firefox/addon/lingua-libre-signit/
MIT License
15 stars 15 forks source link

Fixing POST Request and Refactoring Related Functionality #79

Closed kabir-afk closed 5 months ago

kabir-afk commented 5 months ago

Changes

  1. 8dab00 - Earlier these post requests weren't working and threw error HTTP Status Code 405 Method Not Allowed. The reason that was happening is because ,the URL , POST request was being sent to wasn't being parsed properly. It had some non-URI components which were a part of the query. I was also revealed to the fact that earlier used jQuery post request worked differently as compared to conventional API request which we sent in express or when using axios. $.post added payload data in form of query paramters unlike other methods mentioned before (axios.post/app.post in express). This is the main reason why I was earlier getting error , as even when testing API , I sent payload data in JSON format, which wasn't allowed.

NOTE: The above code needs to be refactored as this is obviously not the way a post request should be sent. Despite it works , it is better to fine tune it for more readability.

  1. The second change is merely a reflection of the first change. Since I was able to make the endpoints work, the functions related to it started working again , and I just commented them out.