My function does not match in the controller My router:
scope "/api", AtmAppWeb do pipe_through :api
get "/index", UserAtmController, :index
get "/show", UserAtmController, :show
get "/get_founds", UserAtmController, :get_founds
post "/create", UserAtmController, :create
put "/update", UserAtmController, :update
delete "/delete", UserAtmController, :delete
end
My controller function:
def get_founds(conn, %{"id" => id}) do
user_atm = User.get_user_atm!(id)
json put_status(conn, :ok), %{"message" => user_atm }
end
and this is my petition:
GET /api/get_founds HTTP/1.1
Content-Type: application/json
Host: localhost:4000
Content-Length: 13
{
"id": "2"
}
I don't know where is the error:
Phoenix.ActionClauseError at GET /api/get_founds no function clause matching in AtmAppWeb.UserAtmController.get_founds/2
i expectted that my function response a message with the atm_user
According to docs, Phoenix.Router.get/4
does not expect a payload as JSON, but rather it expects id
to be a part of path
.
That said, GET /api/get_founds/2
would work as expected assuming the route would be get "/get_founds/:id", UserAtmController, :get_founds
.