Getting "no route found for GET /hello/phoenix (HelloPhoenixWeb.Router)" while following an article

hello from a real frustrated newbe…

I’m reading this article Full-Stack React With Phoenix (Chapter 3 | Introduction to Phoenix) by michael mangialardi from the medium library. in it he’s adding a new Hello controller and I follow the to the letter on all fo the files he creates but I keep getting the error: Phoenix.Router.NoRouteError at GET /hello/phoenix

no route found for GET /hello/phoenix (HelloPhoenixWeb.Router)

and the only thing that is different is he is using version 1.3 of phoenix and I’m using the latest version.

for something this simple both version should work… but alas no matter what I try, it DOES NOT WORK FOR me…

How does your routes.ex look like? What is the output of mix phx.routes?

mix phx.routes output:
Returning_from_des>mix phx.routes
page_path GET / HelloPhoenixWeb.PageController :index
hello_path GET /hello:data HelloPhoenixWeb.HelloController :message
live_dashboard_path GET /dashboard Phoenix.LiveView.Plug :home
live_dashboard_path GET /dashboard/:page Phoenix.LiveView.Plug :page
live_dashboard_path GET /dashboard/:node/:page Phoenix.LiveView.Plug :page
websocket WS /live/websocket Phoenix.LiveView.Socket
longpoll GET /live/longpoll Phoenix.LiveView.Socket
longpoll POST /live/longpoll Phoenix.LiveView.Socket
websocket WS /socket/websocket HelloPhoenixWeb.UserSocket

thank you for your reply

route.ex content:

defmodule HelloPhoenixWeb.Router do

use HelloPhoenixWeb, :router

pipeline :browser do

plug :accepts, ["html"]

plug :fetch_session

plug :fetch_flash

plug :protect_from_forgery

plug :put_secure_browser_headers


pipeline :api do

plug :accepts, ["json"]


scope “/”, HelloPhoenixWeb do

pipe_through :browser

get "/", PageController, :index

get "/hello:data", HelloController, :message


if Mix.env() in [:dev, :test] do

import Phoenix.LiveDashboard.Router

scope "/" do

  pipe_through :browser

  live_dashboard "/dashboard", metrics: HelloPhoenixWeb.Telemetry




Can You provide the lib/hello_phoenix_web/controllers/hello_controller.ex?

here it is:

defmodule HelloPhoenixWeb.HelloController do
  use HelloPhoenixWeb, :controller

  def message(conn, %{"data" => data}) do
    render conn, "hello.html", :data

I don’t know if it is some kind of typo but an important / is missing here between /hello and :data


now I get this… after the / was included:

FunctionClauseError at GET /hello/phoenix

no function clause matching in Phoenix.Controller.render/3

Phoenix.Controller.render/3 expects a Keyword or a Map as assigns, not an atom.

So: render conn, "hello.html", data: data (Keyword), for example, like given in the tutorial you follow

1 Like

As mentionned, You need to add the /

get "/hello/:data", HelloController, :message

It should be

render conn, "hello.html", data: data

The third argument should be a Keyword.

Well, @t0t0 get it right before koko :slight_smile:

thank you, that did it…

I missed the / between the hello and the :data, so I started making changes to see what worked making things worse, now I can continue with my article. thanks again, great job… this really helps…