评估预请求脚本时出错 [英] There was an error in evaluating the Pre-request Script
本文介绍了评估预请求脚本时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过邮寄请求脚本访问邮递员中POST请求的响应。
I'm trying to access the response of my POST request in Postman via Post Request Script.
我在下添加了这两行请求前脚本
let response = pm.response.json();
console.log('JSON Response: ',response );
然后,我打开Postman控制台,然后点击 Send
发出POST请求
Then, I opened up my Postman console, before hit Send
to make my POST request
我一直得到
在评估请求前脚本时出错:TypeError:无法读取未定义的属性'json'
There was an error in evaluating the Pre-request Script: TypeError: Cannot read property 'json' of undefined
我是否需要启用任何功能
Do I need to enable anything on Postman?
推荐答案
在发送请求之前运行了预请求脚本。您还没有响应。
Pre-request scripts are ran before the request is sent. You do not have a response yet.
尝试将脚本放在测试
标签下,该标签会在收到回复。
Try putting your script under the Tests
tab, which is ran after a response is received.
这篇关于评估预请求脚本时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文