Skip to content

Commit

Permalink
adding logging
Browse files Browse the repository at this point in the history
  • Loading branch information
amyfromandi committed Aug 26, 2024
1 parent 7027055 commit 19845f6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions v2/larkin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,19 +645,29 @@ const { Client, Pool } = require("pg");
//get all units and summarize for columns
http.get(
//TODO: cahnge url to match env.
"https://web.staging.svc.macrostrat.org/api/v2/units?all&response=long",
"http://web.staging.svc.macrostrat.org/api/v2/units?all&response=long",
function (res) {
var body = "";

res.on("data", function (chunk) {
body += chunk;
});

console.log(res)
console.log(body)
console.log(res.statusCode)
console.log("redirected to ", res.headers.location)


res.on("end", function () {
var parsedBody = JSON.parse(body);
console.log(parsedBody)
try {
var parsedBody = JSON.parse(body);
// Process the JSON as needed
} catch (e) {
console.error('Failed to parse JSON:', e);
console.error('Response body:', body); // Log the actual body for debugging
}


if (parsedBody && parsedBody.success && parsedBody.success.data) {
var result = parsedBody.success.data;
} else {
Expand Down

0 comments on commit 19845f6

Please sign in to comment.