Skip to content

Commit

Permalink
fix(getItemResources): do not mutate requestOptions in getItemResources
Browse files Browse the repository at this point in the history
Perviously we mutated the requestOptions, but this causes issues if the same requestOptions
instance is used in multiple calls - as in the case of long-promise chains orchestrating complex
interactions with the platform.

AFFECTS PACKAGES:
@esri/arcgis-rest-portal
  • Loading branch information
dbouwman committed Feb 24, 2020
1 parent 25778e3 commit cac63e8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/arcgis-rest-portal/src/items/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,16 @@ export function getItemResources(
): Promise<any> {
const url = `${getPortalUrl(requestOptions)}/content/items/${id}/resources`;

// mix in user supplied params
requestOptions.params = {
...requestOptions.params,
num: 1000
// Mix in num:1000 with any user supplied params
// Key thing - we don't want to mutate the passed in requestOptions
// as that may be used in other (subsequent) calls in the course
// of a long promise chains
const options: IRequestOptions = {
...requestOptions
};
options.params = { ...options.params, ...{ num: 1000 } };

return request(url, requestOptions);
return request(url, options);
}

export interface IGetItemGroupsResponse {
Expand Down

0 comments on commit cac63e8

Please sign in to comment.