List or library - Get items from list with view

Hello, i have a question about list.

I am trying to get items from list but it exceeds the list view threshold.
Can I somehow define the view name/id of that list?

Here is a short snippet of my code:

const targetWeb = new Web("https://name.sharepoint.com/sites/data/test/");
const viewId = "{viewId}";

targetWeb.lists.getByTitle("MyList").items.select("Title").getAll().then(function(items) {
console.log("SelectedItems:", items);
});

Thank you, Marek

Hi @Marek,

Do you have any filtering applied to that list?

SharePoint has issues applying any type of filtering if the list has more than 5000 items. The only workaround is to index the filtered field, this can be done in List Settings. Note that the filtering results shouldn't include more than 5000 items.

Let me know if this helps.