Add log messages to GetUsers endpoint

This commit is contained in:
Evan Fiordeliso 2024-03-07 18:58:42 -05:00
parent 5c76a4b1c3
commit f33aef6e4a
1 changed files with 9 additions and 1 deletions

View File

@ -3,6 +3,8 @@ package users
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"io"
"log/slog"
"net/http" "net/http"
"net/url" "net/url"
@ -51,8 +53,14 @@ func (u *Users) GetUsers(ctx context.Context, params *GetUsersParams) (*GetUsers
} }
defer res.Body.Close() defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
var data GetUsersResponse var data GetUsersResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil { if err := json.Unmarshal(body, &data); err != nil {
slog.Debug("failed to unmarshal", "error", err, "body", string(body))
return nil, err return nil, err
} }