How to extract database values and set them as global variables

Hello, as the title shows, we have successfully accessed MySQL through the postman, requested the database in the interface, and returned the response result. But the value extracted by my previous method of extracting response results is null. How should we correctly extract the response result field value of the database interface? Thank you very much for your advice

Previously, the successful extraction of response results is achieved by:

var Jsondata = JSON.parse(responseBody);

pm.globals. set(“abc”,;

Can you please share a screenshot of an example response (with any confidential information redacted).

This isn’t what is causing your problem, but the JSON.parse method you are using was the old way of parsing JSON responses.

You can now do this through the pm.repsponse object.

const response = pm.response.json();

Postman JavaScript reference | scripting-with-response-data

(post deleted by author)

Thank you for your answer. The method you provided has been used to perform the operation. The response data has been screenshot. How should I extract the ID value in the response result and set it as a global variable

Why a global variable? This means it will be available to all collections.

The scope should probably be set to collection.

Using variables | Postman Learning Center

Your response is an array of Json objects (it’s also a Json object in its own right).

the pm.response.json() parses the JSON into a JavaScript object.

You will need the first element in the array which is [0], and the ID element within.

This should do the trick.

const response = pm.response.json();
let id = response[0].id
pm.collectionVariables.set("variable_name", id);

Thank you for your answer.
Yes, I want to use it for all collections, because I have interfaces for other collections. According to your method, the problem has been solved.
I would like to express my gratitude again. Thank you