@nhayder that's the reponse. But the Network tab has a lot more to offer. Like to check what you are sending to the endpoint.
I've read an issue for an older version of Safari, don't know which version you are running, but there was a problem when passing empty values to the endpoint. So don't know if that's the case for you as well, but why it is not passing any data is strange to me. Just tested my own app, and everything works well, I use axios as well. And my Safari version is > 13.
EDIT
Maybe your url should just be:
/api/widget/text As I don't see the other prefixes that you are applying ie /admin/designer/.
I'm out of ideas here. You basically know Axios is working because you are hitting the end point and getting validation errors.
You tested with hardcoded data, so the data being there isn't the issue.
You tested post so this is just broken.
Probably something conflicting or weird with your setup that is Safari specific.
cc: @nakov
@fylzero you are exactly correct on this.
i just can't make it work
i tried everything but its not working.
@fylzero it's a long file i just copied and pasted part of it, the part where you need to see the actual route.
i have some admin group and designer group then come the api group that one you are looking at above
@nhayder which version of Safari are you using?
@nakov Version 13.0.4 (15608.4.9.1.3)
@nhayder I am running the exact same version. So this is what I tried, just to check:
In web.php
Route::prefix('api')->group(function (){
Route::put('/widget/text', function () {
return ['response' => 'it works!'];
});
});
In a Vue component:
mounted() {
axios.put('/api/widget/text', {'testing': 'Test if it will be returned'});
}
Response:
{
"response": "it works!"
}
So all good. Make sure you try a simple route like this, and that there is no middleware playing around with your request :)
Don't know what else to say. And keep in mind that I understand your reasoning, that it works on Chrome but not on Safari :) no need to repeat it once again. I am just trying to find out why it wouldn't work on Safari. You said that it is not a cache issue neither, so not much more that I can say.
Also tried:
Route::prefix('api')->group(function (){
Route::put('/widget/text', function () {
return request()->all();
});
});
The response is:
{
"testing": "Test if it will be returned"
}
@nakov Thank you man i will definitely check it out and let you know soon
@nakov hi, I have made great improvements regarding my safari problem. after yesterday's discussion, and i was able to see data passed from my component to the controller.
Note i'm using laravel 5.8 with vue.js and vuex as my main javascript library across my app.
i will try to brief you about what i did so both of us will be on the same page.
this is almost same function but i made a test route for is
saveText({commit}, [id, text, name, wIndex]){
axios.put('/admin/designer/api/test/', {
elem: text,
elemName : name,
elemId: id,
})
.then(function (response) {
commit('UPDATE_W_ELEM', [name, wIndex, response.data]);
})
.catch(function (error) {
Event.$emit('requestAlertDanger');
});
},
now in safari/network i have check the request data and they are available on the browser as expected
{
"elem":"INTR O WIDGET","
elemName":"title",
"elemId":6
}
Then i'm hitting the text route and in my controller i have just simple it worked spitted out
public function test(Request $request)
{
return 'Worked';
}
And i can see the work worked available on the page, so basically the data are being submitted properly and received as expected in safari.
all good till this point.
NOW i need to work with actual data so i can save them into the database?
so i replace the (worked ) with actual data like $request->elem; but i'm getting white space in the network response tab ( Resource has not content ) and data is empty ???
public function test(Request $request)
{
return $request->elem; // returning blank/empty
}
i hope i was able to explain it to you?
and do let me know if you think there is a fix for this
And what will this return:
public function test(Request $request)
{
return $request->all();
}
@nhayder and in your controller you have nothing else, just a default one? Any custom middleware or anything?
I really am out of ideas on how the data can get stripped from the request. I tried the same flow, with newer Laravel version though.
So if I don't have anything custom, I would try to upgrade Laravel as well, as there are no breaking changes between 5.8 and 6.* versions.
@nakov yes i have some middlewares but i'm getting same results with or without.
please do let me know if you have a fix.
All the best
@nhayder Do you have use Request at the top of your controller file?
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request; // THIS LINE
class WhateverController extends Controller
{
@fylzero yes i do have is it on the top of the page, otherwise it won't work on chrome, but if you mean the first line at the top??? i put it at the top first line and still not being able to get the data properly i'm still getting
[]
@nhayder As @nakov said... bottom line Axios works in Safari...
I would suggest this... create a fresh Laravel project and bench test Axios. If it works and you are able to pass a request in Safari... that is starting to smell like a package conflicting with something, bad code or possibly bad config.
Test this in a fresh project. If it works... A/B the packages in stock Laravel to what you have. Remove any packages that aren't stock Laravel both in composer.json and package.json. Run composer update composer install then npm update npm install... then try testing again.
If this works you have a conflicting package... so you can start enabling them one by one to figure out which is breaking things.
If this turns out to be the case, you'll need to deal with either finding an alternative package or roll your own code for that feature... or just fork the package and decorate it... which will create some tech debt for you... but this is the last road I would try for this.
If testing in a fresh project doesn't work, something is probably hosed with your machine.
Please or to participate in this conversation.