Skip to content

Instantly share code, notes, and snippets.

@prashantagarwal
Created January 15, 2019 10:57
Show Gist options
  • Select an option

  • Save prashantagarwal/22b4297f85bbb7b5f7dc079afd396f92 to your computer and use it in GitHub Desktop.

Select an option

Save prashantagarwal/22b4297f85bbb7b5f7dc079afd396f92 to your computer and use it in GitHub Desktop.
// I have stored the generated Mock URL as Collection Variable
let snapshotURL = pm.variables.get('snapshotURL'),
/* Create the path that was used in actual request. We will send it along with our Mock endpoint */
path = pm.request.url.path.join('/');
/* If request contains any query params then pass those as well to mock endpoint */
if (pm.request.url.query.count()) {
let params = pm.request.url.query.map((q) => {
return `${q.key}=${q.value}`;
})
path = `${path}?${params.join('&')}`;
}
// This is the final mock request that we will use.
let snapshotFetchOptions = {
url: `${snapshotURL}/${path}`,
method: pm.request.method
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment