arcgis-rest-js icon indicating copy to clipboard operation
arcgis-rest-js copied to clipboard

Add getUserFolders() to portal package

Open dbouwman opened this issue 5 years ago • 1 comments

Folders are returned with the payload of /content/users/{username}. If we pass in ?num=1, the response will only contain a single item, but all the folders.

Below is a working example from the Hub e2e purge system

export function getUserFolders (session) {
  const user = await session.getUser();
  const url = `${session.portal}/content/users/${user.username}?num=1`;
  return request(url, { authentication: session })
    .then((response) => {
      return response.folders || [];
    });
}

I verified that we can fetch folders for other users, so having an optional username param would be useful... I'm not clear what limitations/requirements there are for being able to get another users folders... i.e. does the auth'd user need to be an orgAdmin or can any user get this info? or is there a priv?

dbouwman avatar Oct 02 '20 14:10 dbouwman

turns out this is more of an issue of function naming... getUserContent makes the underlying request, so we can implement this function by just delegating to getUserContent and returning just the folders array.

dbouwman avatar Nov 18 '20 21:11 dbouwman