After spending time developing a REST API that displays information about the planets in our solar system on a local server in .JSON format, I encountered an issue with POST requests. Although GET requests were successful when testing the URL (localhost:8000/planets
) using Postman, I struggled with POST requests.
When switching from a GET request to a POST request on Postman by typing localhost:8000/planets
, entering data, and sending it, the newly added data appeared after a subsequent GET request. However, making changes to the JavaScript file containing the code for POST and GET requests led to the disappearance of the posted data upon performing another GET request on Postman. This unexpected behavior has left me puzzled, indicating a possible issue within my code. Here is the code snippet:
(Code Snippet Provided)
In one instance, while attempting to add data for Neptune, everything seemed to function properly as the new data was visible alongside existing planet information following a GET request on Postman. Yet, upon rectifying a minor typo in the JavaScript file and conducting another GET request, the Neptune data vanished. The confusion surrounding this inconsistency prompts me to seek assistance in resolving this perplexing matter.