Thanks for the quick solution it worked for this project. Actually I have the same clone of the project which has a similar code but not working in the clone.
Following are the details of the code
My routes path are:
signup_path GET / MyDemoWeb.RegistrationController :new
signup_path POST / MyDemoWeb.RegistrationController :create
login_path GET /login MyDemoWeb.SessionController :new
login_path POST /login MyDemoWeb.SessionController :create
logout_path DELETE /logout MyDemoWeb.SessionController :delete
game_path GET /game MyDemoWeb.PageController :index
websocket WS /socket/websocket MyDemoWeb.UserSocket
In layout/templates/app.html.eex, the code for logout link is below:
<%= link "Sign out", to: Routes.logout_path(@conn, :delete), method: :delete %>
In my lib/my_demo_web/controllers/session_controller.ex , the code to logout user is
def delete(conn, _params) do
{:ok, conn} = Pow.Plug.clear_authenticated_user(conn)
redirect(conn, to: Routes.login_path(conn, :new))
end
After click on logout link, it shows me error on the URL: http://localhost:4000/logout
[info] GET /logout
[debug] (Phoenix.Router.NoRouteError) no route found for GET /logout (MyDemoWeb.Router)
(my_demo) lib/phoenix/router.ex:324: MyDemoWeb.Router.call/2
(my_demo) lib/my_demo_web/endpoint.ex:1: MyDemoWeb.Endpoint.plug_builder_call/2
(my_demo) lib/plug/debugger.ex:122: MyDemoWeb.Endpoint."call (overridable 3)"/2
(my_demo) lib/my_demo_web/endpoint.ex:1: MyDemoWeb.Endpoint.call/2
How can I get rid of this GET method I need DELETE method here too as in previous project
NOTE: In the second project besides “npm” I have installed “Yarn” and “Webpack” in this project. I am using Mac OS for this project. Webpack also showing error when I have started my server via command
mix phx.server.
The web pack error is shown below:
webpack is watching the files…
Hash: aaf6f65cd61af081c515
Version: webpack 4.41.0
Time: 1096ms
Built at: 10/05/2019 10:34:22 AM
Asset Size Chunks Chunk Names
…/favicon.ico 1.23 KiB [emitted]
…/images/bitmap.jpg 1.31 MiB [emitted]
…/images/g.png 62.6 KiB [emitted]
…/images/icon-check.png 676 bytes [emitted]
…/images/phoenix.png 13.6 KiB [emitted]
…/images/play-icon.png 17.4 KiB [emitted]
…/images/user.jpg 31.9 KiB [emitted]
…/images/user.png 44.5 KiB [emitted]
…/robots.txt 202 bytes [emitted]
app.js 9.96 KiB ./js/app.js [emitted] ./js/app.js
Entrypoint ./js/app.js = app.js
[0] multi ./js/app.js 28 bytes {./js/app.js} [built]
[./css/main.scss] 1.75 KiB {./js/app.js} [built] [failed] [1 error]
[./js/app.js] 495 bytes {./js/app.js} [built]
+ 1 hidden module
ERROR in ./css/main.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleParseError: Module parse failed: Unexpected character ‘?’ (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Is yarn or webpack error causing any issue in HTML to accept DELETE method I have used in logout link. How can I sort out this issue.