updated for POST and GET requests