我正在开发一个 elixir API,我正在使用 JaSerializer 但它在我调用 post API 时给了我一个类似这样的错误。
function Poison.encode_to_iodata!/1 is undefined (module Poison is not available)
Run Code Online (Sandbox Code Playgroud)
但是在我的配置文件中,我添加了 Poison 并使用 mime 重新编译
mix deps.clean mime --build
mix deps.get
Run Code Online (Sandbox Code Playgroud)
我正在调用的 api 也被插入到数据库中,但它没有响应任何 Json 并给我那个错误。
这是我的配置文件:
use Mix.Config
config :banking,
ecto_repos: [Banking.Repo]
# Configures the endpoint
config :banking, BankingWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: "LMcWbj2QramA5ulI0MZnFobOtrKg/Z2x/gmDl6NwH7hxUbRksPzZjuXwyk8QKGyx",
render_errors: [view: BankingWeb.ErrorView, accepts: ~w(json)],
pubsub: [name: Banking.PubSub, adapter: Phoenix.PubSub.PG2]
# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
config :mime, :types, %{
"application/vnd.api+json" …Run Code Online (Sandbox Code Playgroud)