What to do if UndefinedFunctionError

getting the following error
** (UndefinedFunctionError) function MyWeb.GeolocationController.index/2 is undefined or privat

geolocation

defmodule MyWeb.Geolocation do

  def geo_data(ip) when is_binary(ip) do
    geo_url = Application.get_env(:myweb, :geo_url)

    case HTTPoison.get!("#{geo_url}#{URI.encode_www_form(ip)}") do
      %HTTPoison.Response{body: body, status_code: 200} ->
         body 

      %HTTPoison.Response{status_code: status_code} when status_code > 399 ->
        IO.inspect(status_code, label: "STATUS_CODE")
        :error

      _response ->
        raise MyWeb.Error
    end
  end
end

controller

defmodule MyWebWeb.GeoController do
  use MyWebWeb, :controller

  import MyWeb.Geolocation

  def index(conn, ip, _params) do
    send_resp(conn, 200, geo_data(ip))
  end
end

router

 get "/geo/:ip", GeoController, :index

Your module is MyWebWeb.GeoController not MyWeb.GeolocationController.

Can you show us more of your Router, the full error and what you do to trigger it.

Controller actions are expected to be two-argument functions.

Parameters from the route appear in the second parameter. Your index function head should look something like:

def index(conn, %{"ip" => ip}) do

thanks, that works. but due to this my response is a bit unreadable, is there some way to return a elixir-like map format? I tried with Poison.decode!(body), just body and encode but none of them return something like that

Can you show an example?

its like
“"data”\value""\

Can you show the exact output from IO.inspect? What you’ve pasted isn’t valid elixir code.

It isn’t but that’s the output when I open it in the browser