Need guidance for Debugging the response data

if (res.status === 200) {
const body = JSON.parse(res.body);
const issue =[0].node;
console.log(, issue.number, issue.title);

I didn’t understand in lines 3-5. Please guide me where I can read about this or please explain for me thank!

Hi @Pamorn

Thanks for reaching out! I’m not a GraphQL specialist in any ways, but I’ll give my best to try and support you.

My understanding of your question is that you’d like to know what the operations: JSON.parse(res.body) and[0].node do. Correct?

Assuming that’s the case, and because we were not specific as to what you didn’t understand, I’ll assume no prior knowledge:

  • const body = JSON.parse(res.body) parses the body of the HTTP response as JSON. That means that the body of the HTTP response is treated and interpreted as if it were JSON. Once the JSON.parse(res.body) operation is complete, its result, a JavaScript object matching the JSON document that was received in the body of the HTTP response’s body, is constantly bound to the name body.
  • const issue =[0].node extracts a value from the body object we’ve created during the previous step and binds it in a constant manner to the issue name. Looking at the GraphQL example you pointed from our blog, and being somewhat familiar with the GitHub API, I deduce that the actual body structure looks something like this:
  data: {
    repository: {
      issues: {
        edges: [
            node: ...
          // some other properties...
        // some other properties...
      // some other properties...
    // some other properties...

Thus, the operation[0].node returns the nested node properties of the first object in the edges property of the issues property of the repository property of the data object (that’s a mouthful :slight_smile: ).

So in summary, what the operation you outlined does is: if the result of the request (I assume it’s a GET operation) is successful, parse its JSON body as a JS object (GraphQL is JSON based if I’m not mistaken), bind it to the constant body name, extract the nested node property from it, and bind it to the constant issue name.

I hope it makes sense now. Let me know if that was helpful.

1 Like

yes! This helps me :heart_eyes:, thank you.

another question pls sir.
if I have

export function A

So I get

INFO[0001] "{"data":{"repository":{"issues":{"edges":[{"node":{"id":"MDU6SXNzdWUxNzA0MzczOTY=","number":4,"title":"Deduplicate HTTP client code"}}]}}}}"

first I want to export function B . which uses id from res function A that I got. (MDU6SXNzdWUxNzA0MzczOTY=)

and if it has a way if I create scenarios that


Can I do it’s this way? Thank you!

Hi @Pamorm,

I’ve looked into it. From what you explain, it looks as if you wished to establish some sort of scenario pipeline; where scenario A feeds some data from its result into scenario B. If that’s what you’re trying to achieve, I think you might want to look into the per-vu-iterations executor. A user previously had a request that, I think, is somewhat similar to what you’re looking for.

Let me know if those pointers are helpful, it’s tricky to judge with only a partial view of your process. Don’t hesitate to reach out if you have other questions :+1:

1 Like

This is pretty hard for me to understand :smiling_face_with_tear: .
I think it’s a very good example for learning so I’ll try and come to select it as a solution when I can apply this.
Thank you again!