I am currently starting to use “liveview” in my app, but I have a problem getting the value of a form entry.
I can’t find the reason why I can’t.
Could you help me identify where the problem is?
Liveview
defmodule MyappWeb.LiveRequest do
use Phoenix.LiveView
def render(assigns) do
~L"""
<h1 id="myHeader"><%= @deploy_step %></h1>
<div class="input-group input-group-sm">
<label>Domínio: </label>
<input type="text" name="params" list="matches" placeholder="Domínio..." class="form-control">
<span class="input-group-append">
<button phx-click="checkdomain" type="button" class="btn btn-info btn-flat">Checar Domínio!</button>
</span>
</div>
"""
end
def mount(_session, socket) do
{:ok, assign(socket, params: nil, deploy_step: "Aguardando para busca!")}
end
def handle_event(checkdomain", %{"params" => params}, socket) do
url = "https://myapi.com/v2/test/list/full/#{params}"
response = HTTPoison.get!(url)
registrobr = response.body |> Poison.decode!()
status = registrobr["fqdn"]
{:noreply, assign(socket, params: params, deploy_step: status)}
end
end
Always returns me null