You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I am going through the simple api authentication blog post.
When i try to insert the header in to the response i get the following error ** (exit) an exception was raised: ** (FunctionClauseError) no function clause matching in Plug.Conn.put_resp_header/3
You're passing exp as an integer and not a string.
Fix it from this: Plug.Conn.put_resp_header(new_conn,"x-expires", exp)
to this: Plug.Conn.put_resp_header(new_conn, "x-expires", "#{exp}")
I'd also recommend to take advantage of the pipe operator like so:
I'm sure this this function is in a controller and is __using__ the :controller behavior. So you don't have to prefix put_resp_header with Plug.Conn as it's already imported. So just using put_resp_header will do like the example I gave above.
@keithalpichi Thank you that fixed it.
It might be necessary to update the blog post though i am probably the only one who would not notice.
Closing the issue
Hello,
I am going through the simple api authentication blog post.
When i try to insert the header in to the response i get the following error
** (exit) an exception was raised: ** (FunctionClauseError) no function clause matching in Plug.Conn.put_resp_header/3
My code looks like this
` defp update_user(conn, user, user_params) do
end `
Do you have any idea?
Regards,
K
The text was updated successfully, but these errors were encountered: