I have created an Endpoint Api and I would like it to download an .xls file (.xls export).
here is my endpoint :
public function exportXls(Request $request): Response|BinaryFileResponse
{
return (new UserExport())->forCustomer($request->id)->download('user.xlsx', Excel::XLSX);
}
I can download the file when the function isn't in the api controller but when I switch to Api I can't, I have to retry a response()->download but I don't know how
someone to help me please
I know where is the problem, I have to return a response, but I don't know how, if I do response()->(new UserExport())->forCustomer($request->id)->download('user.xlsx', Excel::XLSX); it is underline in red
@Sinnbeck I'm sorry I didn't explain it well
So in my front-end page I have a button named "export .xls".
The purpose of this button is to download an .xls file.
when I click on the button I access well in the function (i tested with a dd()) but nothing happens and when i inspect element > network in the response there is the weird code i sent you before.
What if you open the url directly in a browser tab ? => nothing happens