I'm not sure if you have a missing forward slash as
serverUrl = "http://localhost:8000/api";
...
this.serverUrl+'count' // gives you http://localhost:8000/apicounts";
Maybe a typo. If not I'm not sure from description what your exact issue is.
i am using http in angular and send post request to the lumen backend but its redirect as a get Post request from http is working i case i send post request to other server but for my lumen db it redirect to get hear is my http call
postCountsData(data: any) {
let options = this.createRequestOptions();
return this.http.post(this.serverUrl+'counts', {duroodCount: 11}, {headers: options});
}
hear is the url private serverUrl = "http://localhost:8000/api";
these are my request header
private createRequestOptions() {
let headers = new HttpHeaders({
"Content-Type": "application/x-www-form-urlencoded"
});
return headers;
}
// routes of lumen
$router->group(['prefix' => 'api'], function () use ($router) {
$router->get('counts', ['uses' => 'CountsController@showAllCounts']);
$router->post('counts', ['uses' => 'CountsController@create']);
$router->get('counts/{id}', ['uses' => 'CountsController@showOneCount']);
$router->put('counts/{id}', ['uses' => 'CountsController@update']);
$router->delete('counts/{id}', ['uses' => 'CountsController@delete']);
});
this is the create method of controller
public function create(Request $request)
{
$Counts = Counts::create($request->all());
return response()->json($Counts, 201);
}
this is the output
Request URL:http://localhost:8000/api/counts
Request Method:GET
Status Code:201 created
Please or to participate in this conversation.