javascript - 我需要使用数组列表发送请求循环
问题描述
当我完成一个请求时,我将在 collectionVariables 中创建一个数组来存储来自响应的 Id。然后我需要使用这个数组来发送删除我所有内容的请求
(存储ID)
const idArray = pm.collectionVariables.get("idArray2"); response = JSON.parse(responseBody); // const array = []; const id = response.items[0].sys.id; // array.push(id); // entryId = pm.response.json().items[0].sys.id; idArray.push(id); // arrayValue = pm.collectionVariables.get("idArray"); console.log(idArray); // pm.collectionVariables.set("arrayValue", array); // arrayValue.push(id);
要删除这些内容,我需要使用 forEach 函数循环。为此,我需要在 {{ID}} 端点中设置数组信息
var submitUnpublishedRequest = {
url: pm.variables.replaceIn('https://api.contentful.com/spaces/{{spaceId}}/environments/{{branch}}/entries/{{ID}}/published'),
method: 'DELETE',
header: {
'Authorization': "Bearer " + pm.environment.get("contentManagementToken"),
'aeg-event-type': pm.environment.get("event_type"),
'aeg-sas-key': pm.environment.get("sas_key"),
'Content-Type': "application/json"
},
body: {}
}
pm.sendRequest(submitUnpublishedRequest)
我的问题是,如何循环此预请求以删除我的内容?
解决方案
推荐阅读
- vue.js - Vuetify垂直对齐v-select?
- json - 使用 rust serde 反序列化不同的数据结构
- flutter - 在颤振上从firestore获取数据创建listview
- c# - 在 iText7 中使用 pdfHTML 添加目录
- optimization - clang/LLVM ARM ABI,非易失性寄存器被破坏
- python - Discord.py 删除角色
- c# - 绑定 RadioButton GroupName
- android - 如果我使用单个活动和导航组件,如何设置折叠工具栏?
- mysql - 仅当sqlite3中的其他列相同时,如何查询列总和?
- xslt - 为什么我的数据列表不会显示在我的 XML 中?