6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Phoenixのapiでsessionを使う時に(ArgumentError) session not fetched, call fetch_session/2が出た時の対処

Last updated at Posted at 2016-03-08

環境

OS X Yosemite 10.10.5
Phoneix 1.1.4
Erlang OTP 18 erts-7.2.1
Elixir 1.2.2

原因

デフォルトでapiのパイプライン上にsessionをfetchする部分が無い事が原因

対処

web/router.ex
pipeline :api do
  plug :accepts, ["json"]
  plug :fetch_session # ←これを加える
end

※ 2019-02-20追記
この編集を書いてる時点でのファイルパスはlib/app_name_web/router.exです

雑記

sessionがfetchできねぇ!fetch_session/2をcallしてくれ!って言われて???ってなってたので、fetch_sessionとはなんぞやから始まった

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?