I need to build a personaliced response to get one URL returned from API. In my function store i´m saving all data in my db ok. I have a personaliced class that this class have any method to connect API and return response, etc. In my function store, i have this call:
return redirect()->route('commercialautograph.precontract', ['precontract' => $precontract]);
This call return response from API:
$response = $this->client->request('POST', $url, [
'auth' => [config("viafirma.apiKey.username"), config("viafirma.apiKey.password")],
'json' => $json
]);
return $response;
if i build mehtod in my controller to get link from API, return BASE64´s pdf that i i´m sending to API. that's why i´m building redirect to other route, to close other operations. But my problem it´s that when i´m doing redirect, laravel returned me HTML:
{data: '<!DOCTYPE html>\r\n <html lang="en">\r\n <he…\n\r\n </div>\r\n \r\n </body>\r\n</html>', status: 200, statusText: 'OK', headers: {…}, config: {…}, …}
This example it´s a webrowser console.
My route is:
Route::prefix('commercial')->name('commercial')->group(function(){
Route::get('autograph/{precontract}', [CommercialPreContractController::class, 'autograph'])->name('autograph.precontract');
}
this route call other function in my same controller, that in this moment i want to arrive to function:
/**
* Function to digital signature precontract
*/
public function autograph(Array $precontract)
{
echo "llego¿?";
exit();
try{
I haven´t got any problem in logs.. And i don´t know that i´m doing wrong, but i can´t arrive to my function. I can´t to do $this->autograph
beacause i need return response from API and read it in VUE js
I hope that anybody can help me.
Sorry for my bad english and thanks you very much for readme.
route list:
GET|HEAD commercial/autograph/{precontract} commercialautograph.precontract › Commercial\CommercialPreContractCont…
You cannot send array of data as path parameters, it will not be mapped to any route. This will not work with any route method POST, GET, etc.
Remove {precontact}
from path param, give it a static name e.g. commercial/autograph/precontact
so this will be a static route. Send to that endpoint specific query (GET) parameters e.g. id, name ?id=...&name=...
etc.
Also public function autograph(Array $precontract)
does not work for any kind of data. Array $precontract
is invalid for controllers in Laravel. It should be replaced with public function autograph(Request $request)
see laravel docs. From there get the params like $request->input('id')
.
So after all these the redirect command will be
return redirect()->route('commercialautograph.precontract', ['id' => $precontract['id'], 'name' => $precontract['name']);