Merge tables (with the same column names) from SharePoint in javascript

Viewed 14

I am trying to connect two tables with the same column names. Usually when I fetch one table it displays it as an array of objects. Each object presents one table row. I.e.

[
{
 col1: someValue,
 col2: otherValue,
 .
 .
},
{
 col1: someValue2,
 col2: otherValue2,
 .
 .
},
]

And I want to merge another table with the same structure, so I would have again array of objects, just with objects(rows) from first and second table.

I am using the code bellow, but I can't get the second table in the response:

const alleDokumente = {
  getAlleDokumente: () => {
    return $SP()
      .list("Documents_1", spBaseUrl)
      .get({
        json: true,
        fields:
          "Title, Document_x0020_Name, Date, Year, Comments, Document_x0020_Number, Committee, Category, ",
        merge:[{
          list: "Documents_2",
          json: true,
          fields:
            "Title, Document_x0020_Name, Date, Year, Comments, Document_x0020_Number, Committee, Category, ",
        }],
      }).catch((err) => console.log(err.responseText));
  },
};
0 Answers
Related