{ "info": { "_postman_id": "6bfcc5ce-a01d-4ff4-ba2e-9dbc06ce6a82", "name": "MusicBands", "description": "See the documentation of the `Dummy-request`.", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "Dummy-request", "event": [ { "listen": "test", "script": { "exec": [ "const lock = setTimeout(() => {}, 43210);\r", "const albumsArray = [];\r", "const urlsArray = [];\r", "const urlOuter = 'https://musicbrainz.org/ws/2/artist/' +\r", " pm.collectionVariables.get('MBID') + '?fmt=json&inc=url-rels+release-groups';\r", "pm.sendRequest(urlOuter, (_, responseO) => {\r", " const bandName = responseO.json().name;\r", " const albums = responseO.json()['release-groups'];\r", " for (const item of albums) {\r", " albumsArray.push(item.title);\r", " urlsArray.push('https://coverartarchive.org/release-group/' + item.id);\r", " }\r", " albumsArray.length = urlsArray.length = 15;\r", " const images = [];\r", " let countDown = urlsArray.length;\r", " urlsArray.forEach((url, index) => {\r", " asynchronousCall(url, imageURL => {\r", " images[index] = imageURL;\r", " if (--countDown === 0) { // Callback for ALL starts on next line.\r", " clearTimeout(lock); // Unlock the timeout.\r", " const albumTitles = albumsArray.map(value => ({ title: value }));\r", " const albumImages = images.map(value => ({ image: value }));\r", " const albumsAndImages = albumTitles.map(\r", " (item, i) => Object.assign({}, item, albumImages[i]));\r", " const template = `
` + bandName + ` |
---|
{{title}} |