Created
July 14, 2018 03:23
-
-
Save JakeTheCorn/f0d6b3d83326eb49f8d32d61756d2755 to your computer and use it in GitHub Desktop.
DELETE example 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 destroyFriend() { | |
resourceURL := "http://rest.learncode.academy/api/johnbob/friends/5b496c3b79f71d000f953fac" | |
req, err := http.NewRequest("DELETE", resourceURL, nil) | |
if err != nil { | |
panic(err) | |
} | |
res, err := http.DefaultClient.Do(req) | |
if err != nil { | |
panic(err) | |
} | |
defer res.Body.Close() | |
body, err := ioutil.ReadAll(res.Body) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Println(string(body)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment