Last active
November 5, 2022 17:51
-
-
Save Ipanov7/925041d0f77028a7addaeb2718d2abec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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