Created
July 13, 2018 17:39
-
-
Save JakeTheCorn/21dcdd04381298e0265d9f50b100c9a1 to your computer and use it in GitHub Desktop.
How to fetch JSON in Go
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 getFriends() { | |
resp, err := http.Get("http://rest.learncode.academy/api/johnbob/friends") | |
if err != nil { | |
panic(err) | |
} | |
bytes, err := ioutil.ReadAll(resp.Body) | |
if err != nil { | |
panic(err) | |
} | |
stringBody := string(bytes) | |
fmt.Println(stringBody) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment