# |
Apr 19th 2017, 15:30 |
Erik180486 |
Cake\Event\Event given, called in /vendor/cakephp/cakephp/src/Event/EventManager.php |
# |
Apr 19th 2017, 15:29 |
Erik180486 |
anyone has any idea what this error means: Argument 1 passed to App\Controller\UsersController::beforeFilter() must be an instance of App\Controller\Event, instance of |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
https://www.getpostman.com/ |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
I’d hit stuff with Postman to check the api at least |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
Your setup sounds okay to me |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
As XMLHttpRequest isnt’ supported in Internet Explorer or something like that |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
Oh, are you not wrapping the Javascript in something? |
# |
Apr 19th 2017, 15:25 |
crazycoder |
Neon1024, ^^ |
# |
Apr 19th 2017, 15:24 |
crazycoder |
then i have seen that if i do not use XMLHttpRequest the component does not get the request....! |
# |
Apr 19th 2017, 15:23 |
crazycoder |
is this wrong ? |
# |
Apr 19th 2017, 15:23 |
crazycoder |
i have Router::extensions(['json', 'xml']); <-- in the main routes.php and $this->loadComponent('RequestHandler'); in the API appcontroller.php |
# |
Apr 19th 2017, 15:22 |
crazycoder |
on the main routes.php |
# |
Apr 19th 2017, 15:22 |
Neon1024 |
Ahok |
# |
Apr 19th 2017, 15:22 |
crazycoder |
inside the API routes.php NO but i have Router::extensions(['json', 'xml']); |
# |
Apr 19th 2017, 15:22 |
Neon1024 |
And the RequestHandlerComponent to allow auto-content type switching |
# |
Apr 19th 2017, 15:22 |
Neon1024 |
Router::extensions(['json']); |
# |
Apr 19th 2017, 15:22 |
Neon1024 |
Ah, perhaps you haven’t set the extensions in your routing? |
# |
Apr 19th 2017, 15:21 |
crazycoder |
so i think i must set headers |
# |
Apr 19th 2017, 15:21 |
crazycoder |
i get html output |
# |
Apr 19th 2017, 15:21 |
crazycoder |
Neon1024, /api/sdfsfsdfsdf.json <--- |
# |
Apr 19th 2017, 15:21 |
crazycoder |
ok |
# |
Apr 19th 2017, 15:20 |
Neon1024 |
Plus it is more inline with jsonapi.org |
# |
Apr 19th 2017, 15:20 |
Neon1024 |
I had a requirement to use headers as I wasn’t allowed to use .json |
# |
Apr 19th 2017, 15:19 |
Neon1024 |
As Cake allows both .json extension and headers |
# |
Apr 19th 2017, 15:19 |
Neon1024 |
If you use a .json extension it should come back as json |
# |
Apr 19th 2017, 15:19 |
crazycoder |
*create |
# |
Apr 19th 2017, 15:19 |
crazycoder |
i will crate a midleware too |
# |
Apr 19th 2017, 15:19 |
crazycoder |
ah ok awesome |
# |
Apr 19th 2017, 15:19 |
crazycoder |
ok but after the headers? |
# |
Apr 19th 2017, 15:19 |
Neon1024 |
The exception error will be rendered as normal, but json instead of html :) |
# |
Apr 19th 2017, 15:19 |
Neon1024 |
To set the headers based on the route for my api |
# |
Apr 19th 2017, 15:18 |
Neon1024 |
I’ve used a middleware class |
# |
Apr 19th 2017, 15:18 |
crazycoder |
and what will be rendered? |
# |
Apr 19th 2017, 15:18 |
crazycoder |
k |
# |
Apr 19th 2017, 15:18 |
Neon1024 |
I always get them confused but I think it’s the Content-Type header |
# |
Apr 19th 2017, 15:18 |
Neon1024 |
You need to set the header on the response to application/json |
# |
Apr 19th 2017, 15:17 |
crazycoder |
Neon1024, how? because if i do website/blablablabla i get the html NOT found page |
# |
Apr 19th 2017, 15:17 |
Neon1024 |
I use the default exceptions, but I’ve had to make my own exception renderer to customise the json output |
# |
Apr 19th 2017, 15:17 |
Neon1024 |
Yep |
# |
Apr 19th 2017, 15:16 |
crazycoder |
Neon1024, is there a way to render the error on a json call? |
# |
Apr 19th 2017, 15:13 |
sjundee |
Hi! Anyone who has experience working with CSV? When my title row is the very first line in the file, the first element `$cols[0]` isn't found in `array_search()`. I try `$key_id = array_search('Id', $cols)`, but when it is on the very first line, it doesn't work. When it after the first line, I get what I expect. |