my original purpose was to send a request using node + superagent to request several existing interfaces, but now I have a problem. I need to send a data (send)
in the request.request
.post(url)
.send({item})
but the content of item is to construct a questionnaire. The structure of the questionnaire is probably a tree structure with multiple layers of nesting
{
a: a,
b: b,
c: {
c1: c1,
c2: c2,
},
d: {
d1: d1,
d2: {
d3: d3,
d4: d4
}
}
}
after repeated studies, it seems that the most suitable way to construct a questionnaire is to use a tree structure to construct a questionnaire. However, since the deepest nesting layer has about four layers, if you want to quote the questionnaire into the variable item and then send it, first of all, item will not be able to print the complete questionnaire, and then the server will not even receive the outermost data after sending it out. So if you want to ask how to integrate a multi-layer nested data in the request, you need to keep the complete contents of the questionnaire, including keys and values, because the method of traversing only retains the values. But I need to send all the above so that the server can identify each item in the questionnaire.