actually return response value

This commit is contained in:
Branden J Brown 2025-03-13 22:54:16 -04:00
parent 62c9693788
commit ecea53685f

View File

@ -28,6 +28,9 @@ func writeError(w http.ResponseWriter, status int, msg string) {
}
func readResponse[T any](r *http.Response) (x T, err error) {
if r.StatusCode != http.StatusOK {
return x, errors.New(r.Status)
}
var b struct {
Data T `json:"data"`
Error string `json:"error"`
@ -38,7 +41,7 @@ func readResponse[T any](r *http.Response) (x T, err error) {
if b.Error != "" {
return x, errors.New(b.Error)
}
return x, nil
return b.Data, nil
}
type neighbors struct {