//Set key and get value from document and store to temporary array $tmp["name"] = $doc["name"]; $tmp["age"] = $doc["age"]; //push temporary array to $result array_push($result, $tmp); } //show result response(200, $result); }); //Post Friends end point $app->post('/friends', function () use($app) { $res = array(); $name = $app->request()->post('name'); $age = $app->request()->post('age'); $db = new dbHandler(); $cur = $db->insertFriend($name, $age); if ($cur == INSERT_COL_SUCCESS) { $res["error"] = FALSE; $res["message"] = "Success to insert a new friend"; response(201, $res); } else { $res["error"] = TRUE; $res["message"] = "Failed to add a new friend"; response(200, $res); } }); //Delete friend end point /* $app->delete('/friends/:name', function($name){ $res = array(); $db = new dbHandler();