Skip to content

Instantly share code, notes, and snippets.

@Ipanov7
Last active November 5, 2022 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ipanov7/925041d0f77028a7addaeb2718d2abec to your computer and use it in GitHub Desktop.
Save Ipanov7/925041d0f77028a7addaeb2718d2abec to your computer and use it in GitHub Desktop.
func fetchRate(from string, to string) float64 {
url := fmt.Sprintf("https://api.apilayer.com/exchangerates_data/convert?to=%s&from=%s&amount=1", to, from)
client := &http.Client{}
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("apikey", apikey)
res, _ := client.Do(req)
body, _ := io.ReadAll(res.Body)
quote := parseQuote(body)
return quote.Result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment