DEV Community

Discussion on: http.Post Golang example

Collapse
 
clavinjune profile image
Clavin June

Great post!

Actually, you can use this snippet below instead of using ioutil.ReadAll and json.Unmarshal

var data map[string]interface{}
if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
    log.Fatalf("Failed to read response body: %v", err)
}
Enter fullscreen mode Exit fullscreen mode