nodejs
nodejs copied to clipboard
getContactByEmail throws exception if no contact found
If no contact is found the response body is an empty string. The code attempts to parse this as JSON and throws an exception. This implies that the code has failed but an empty response is a valid response as there may well be no contact in the database with a specific email address.
Proposal is to check the body and if the body is an empty string return undefined.