How to use jsonp for some api route by easy way?
- Dominant language
- PHP
- Stars
- 9.4k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
I try
```php
'formats' => [
'json' => Dingo\Api\Http\Response\Format\Json::class,
'jsonp' => Dingo\Api\Http\Response\Format\Jsonp::class,
],
```
```php
return response()->jsonp('test', [‘foo’ => 'bar']); // blank
return $this->response->array(['foo' => 'bar'])->morph('jsonp'); // {"message":"Trying to get property of non-object","status_code":500}
```
```php
$formatter = new Jsonp();
$formatter->setRequest($request);
$response = $this->response->array(['foo' => 'bar']);
$response->addFormatter('jsonp', $formatter);
$response->morph('jsonp');
return response($response->getContent())->withHeaders([
'Content-Type' => 'application/javascript',
]);
```
Its work!
But Its to complex. there is some easy way to do this?
Contributor guide
Assessment
This issue has not been assessed yet.