refactored the GET and POST request to return JSON instead of the response