Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问我应该如何判断POST里面的Key值 #16

Open
KingOfSu opened this issue Apr 25, 2024 · 3 comments
Open

请问我应该如何判断POST里面的Key值 #16

KingOfSu opened this issue Apr 25, 2024 · 3 comments

Comments

@KingOfSu
Copy link

查看说明文档有这个

const { method, payload, originalResponse } = arguments[0];
if (method === 'get') { // Method
// do something
}
if (payload) { // parameters { queryStringParameters,requestPayload }
// do something
}

return {
"status": 200,
"response": originalResponse
}

但是 payload 注释相关的方法报红色,本人对前端不太了解,想请教下!谢谢!

@PengChen96
Copy link
Owner

你是要判断post请求的入参吗,这个payload就是,你可以根据这个判断,你可以写个console.log去打印出来看看。
注释红色你可以把语言切换成javascript。

@KingOfSu
Copy link
Author

你是要判断post请求的入参吗,这个payload就是,你可以根据这个判断,你可以写个console.log去打印出来看看。 注释红色你可以把语言切换成javascript。

对的,之前可能忘记save了,然后修改后一直没有啥变化。

试着用掘金的首页滑动列表来进行尝试下

Request URL: https://mcs.snssdk.com/list
Request Method: POST
Status Code: 200

通过console.log打印确实有 queryStringParameters requestPayload两个类别。后面又想尝试读取其中的关键字,以为是还要JSON.parse。转换后报错 SyntaxError: "[object Object]" is not valid JSON ,说明是个对象,我就试着直接复制后面的requestPayload来进行打印,也确实有哈哈哈。就是网页的那个编辑器貌似读取不到object的变量,对我这个新手还是比较困扰。

问题完美解决了,对相同的网页通过不同的post数据返回不同值有解决方案了。谢谢!

可以冒昧的请教下,现在前端有啥好入门的学习书籍吗?有java基础经验(Android开发),我看了JavaScript相关入门书籍,对于这些还挺吃力的0.0

@PengChen96
Copy link
Owner

JS基础可以看看这个https://es6.ruanyifeng.com/#docs/intro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants