#No query results for model [AppModelsUser] me
1 messages · Page 1 of 1 (latest)
it's easier if you dont answer
Sure thing bud. That will take you far.
OAuth aside, taking one request to dispatch it internally to another controller is such an antipattern.
i literally copied that from another project from uni classes, so i guess teachers are teaching us bad pratices
Watch the attitude.
even if this is a bad practise, i shouldnt get 404 from users/me
Also, the #rules state not to post screenshots but to post code instead.
sorry my bad
route:list is showing me that endpoint
kinda weird to get 404 not found
like it doesnt even exist 🤔
@abstract urchin The error is saying you’re trying to query your user model with an ID of “me”, which suggests you have another route taking precedence that looks a user up by ID.
Just my observation, but if you indeed got that from uni, then that worries me. I can understand not knowing that the password grant type has been considered bad practice and should be phased out. But on top of that, you are
- Using
emv()helper outside of your configuration files
https://laravel.com/docs/9.x/configuration#configuration-caching
If you execute the config:cache command during your deployment process, you should be sure that you are only calling the env function from within your configuration files. Once the configuration has been cached, the .env file will not be loaded; therefore, the env function will only return external, system level environment variables.
- overwriting the request to dispatch to an internal route
- OAuth and "logout" do not go together
yeah ive got users/{id} and users/me
hmm however ive got users/chef and users/manager and it is working
nah it is not that
ive deleted every endpoint about users
i didnt work...
So show what error you’re getting.
You’re not sending a JSON request properly.
So you’re just getting a HTML response and I have no idea what the error is, but it’s not the “same” as before.
it is the same, i was just showing the erro from console/postman
but inside network tab, i still have the same error message
You’re still trying to query a user model with a primary key of “me”
ik this is laravel discord, but im using axios on vue (frontend)
That doesn’t change what I’ve said twice now?
const response = await axios.get('users/me')
The problem is server side. Has nothing to do with Axios or anything else about your JavaScript.
can you more clear about the error?
what can be causing it?
why it is looking for "me" as id
I don’t know, mate. It’s your code.
You need to actually work out which controller action is being hit.
the endpoint is well defined inside api.php
and the controller is associated to it
route:list shows that as well
And what’s that got to do with what I’ve just suggested?
ive got no clue on what youve just suggested
I’ve just suggested you actually need to verify what controller action is responding to the request.
Instead of just guessing or assuming.
no its not
Because it clearly isn’t the action you think it is.
ive already did that
i tried to return a response with a msg and status code
and it didnt do nothing, so it isnt calling that endpoint
…
however i cant understand why it isnt calling it
You’ve already been told: you have another route taking precedence.
And?
middleware auth:api group function, login, logout and users/me
And?
You. Still. Need. To. Verify. Which. Controller. Action. Is. Actually. Handling. The. Request.
You’re just shooting in the dark and then acting confused why you’re not hitting anything.
can you tell me how to do that? youre talking about attittude but youre the one with it
Because you keep getting told the same thing multiple times yet want to give me unrelated information and answers to questions I haven’t asked.
You have a route responding to that request. Use php artisan route:list --path=api/users to get a list of candidates.
So look at all those routes, including the ones that take an ID…
You also seem to be caching routes. Don’t.
Delete your route cache, and never run in development again.
the problem is if all those routes are commented and ive just cleared the cache, how can they be accessing a diferent route?
I don’t know because you still haven’t identified which one is actually handling the request.
I know it is an old post , but I was getting the same error when building an API and didn't found anywhere. I know a possible solution and explanation about this. I'm posting here because maybe someday someone will take a look at this post having the same problem. Did you solve the problem @abstract urchin ?
The problem is that you have two or more routes with the same name, for example:
GET|HEAD api/users/delivery
GET|HEAD api/users/me
GET|HEAD api/users/{id}
What happens is that when laravel builds the route api/users/{îd}, anything can be sent to {id} portion, so it could be 123 or yadayada. So, whenever a request is made for api/users/me or api/users/delivery, laravel thinks it is for api/users/{id}, and then tries to load the model.
I had the same error happening and was losing my mind on it, and it was simple. If there wasn't the route api/users/{id} then laravel can read both api/users/me and api/users/delivery correctly.
I hope it helps anyone seeing this.
The simplest solution to this would be:
Route::get('users/{id}', ['UserController', 'show'])->where('id', '[0-9]+');