actually return response value
This commit is contained in:
parent
62c9693788
commit
ecea53685f
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user