Skip to content

Commit

Permalink
Skip status 204 as error if the delete method is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
ErnestNeller committed Dec 26, 2023
1 parent 313eb67 commit d32f229
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ func (client *Client) sendRequest(req *http.Request, dest interface{}) error {
client.logger.Debug(string(body))
}

if resp.StatusCode != http.StatusOK {
return &unexpectedStatusError{
status: resp.StatusCode,
url: req.URL,
if req.Method != http.MethodDelete && resp.StatusCode != http.StatusNoContent {
if resp.StatusCode != http.StatusOK {
return &unexpectedStatusError{
status: resp.StatusCode,
url: req.URL,
}
}
}

if dest != nil {
if dest != nil && len(body) > 0 {
if err := json.NewDecoder(bytes.NewReader(body)).Decode(dest); err != nil {
return fmt.Errorf("directus: cannot decode response: %v", err)
}
Expand Down

0 comments on commit d32f229

Please sign in to comment.