Using var body []byte
like this creates slice with a capacity 0. Passing this into Read()
means that it will try to fill the capacity-0 slice with bytes. Since the slice has no more capacity, it returns with no error, and with the "empty" slice.
Replacing it with body, err := io.ReadAll(resp.Body)
works, since io.ReadAll()
consumes the entire Reader and returns it as a []byte
.