# frozen_string_literal: true require "net/http" require "json" class WahComponent < ViewComponent::Base def initialize(legacy:) if legacy then else uri = URI.parse('https://api.tinyfox.dev/img.json?animal=wah') req = Net::HTTP::Get.new(uri.to_s) res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) {|http| http.request(req) } data = JSON.parse(res.body) url = "https://tinyfox.dev" + data["loc"] @wah_url = url end end end