Skip to content

Commit

Permalink
chore: check to confirm api test response is an obj
Browse files Browse the repository at this point in the history
  • Loading branch information
HardeepAsrani committed Jul 31, 2024
1 parent 32660ee commit d2ed9e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion inc/server/class-prompt-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function save_api_key( $request ) {
$body = wp_remote_retrieve_body( $response );
$body = json_decode( $body );

if ( json_last_error() !== JSON_ERROR_NONE ) {
if ( json_last_error() !== JSON_ERROR_NONE && ! is_object( $body ) ) {
return new \WP_Error( 'rest_invalid_json', __( 'Could not parse the response from OpenAI. Try again.', 'otter-blocks' ), array( 'status' => 400 ) );
}

Expand Down

0 comments on commit d2ed9e4

Please sign in to comment.