Weird error when testing API?

Hi, I starting adventage with adonis and build API.

I finded in routing doc and pick:
Route.resource('users', 'UserController').apiOnly()

In addition I choose PostgreSQL as my database.
When I tested API endpoints (using Postman), I discover something intrest.

I select “/users/2/edit” endpoint and connect with ~ as response I recieve: E_ROUTE_NOT_FOUND: Route not found GET - this is what happens ordinary (apiOnly ~ disabled these routes).

But with “users/create” endpoint I recieve:
select * from "users" where "id" = $1 limit $2 - invalid input syntax for integer: "create"

Both routes doesn’t exists in controller, I suppose second query should receive the same error. I don’t know it’s bug?

1 Like

I guess you’re getting that error because since you used the .apiOnly() method, the router takes “users/create” as “users/:id”. So it is taking “create” as if it was an id from a User you’re looking for.

Therefore, I guess the router takes the route as the SHOW one, which is a Route that apiOnly does implement:

Route.get('users/:id', '').as('')