This section duplicates the code in parse-http excepting the JSON conversion, please keep it DRY by splitting the repeated code into a separate function.