Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Render an image with Kino

render-image.livemd

Render an image with Kino

Mix.install([
  {:req, "~> 0.4.0"},
  {:kino, "~> 0.12.3"}
])

Code

user =
  Req.new(
    base_url: "https://api.github.com/users/1-bit-wonder",
    headers: %{
      authorization: "bearer " <> System.fetch_env!("LB_GITHUB_TOKEN"),
      accept: "application/vnd.github+json"
    }
  )

{:ok, res} = Req.get(user)

avatar_url = res.body["avatar_url"]
{:ok, avatar} = Req.get(avatar_url)

Kino.Image.new(avatar.body, "image/jpeg")