?文章來源:http://www.zghlxwxcb.cn/news/detail-691015.html
具體前置腳本如下:?文章來源地址http://www.zghlxwxcb.cn/news/detail-691015.html
// pm.request.body.update 處理 body 參數(shù)里的變量
let bodyStr = pm.request.body.raw;
// base64 編碼數(shù)據(jù)
let bodyEncode = btoa(bodyStr);
console.log(bodyEncode)
let newBody = {
"data": bodyEncode,
"sendTime": "2023-08-29 15:00:00"
}
// 更新body,需要轉(zhuǎn)成json字符串
pm.request.body.update(JSON.stringify(newBody, null, 2));
console.log(pm.request.body.raw)
到了這里,關(guān)于使用apifox前置數(shù)據(jù)base64編碼并添加一個字段的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!