[英]jquery POST params
I have a function that is making a POST call and I keep getting this for a response from the server: 我有一个正在执行POST调用的函数,并且不断从服务器获取响应:
{
"error": "Bad Request",
"status": 400,
"message": "Missing required parameter client_id"
}
This is the function I'm using to make the POST call: 这是我用来进行POST调用的函数:
function isUserRegistered() {
user_code = localStorage.getItem('LSuserCode');
// POST for user object
$.post("https://api.twitch.tv/kraken/oauth2/token", {
client_id: clientID,
client_secret: clientSecret,
grant_type: 'authorization_code',
redirect_uri: redirectURI,
code: user_code
},
function(data) {
grabUserAccessTok(data);
});
}
It's complaining that I am missing a required "client_id" parameter but as you can see from my POST call, it is in there. 抱怨我缺少必需的“ client_id”参数,但是正如您从我的POST调用中看到的那样,它在那里。 What am I doing wrong? 我究竟做错了什么?
Looking at your JQuery code, it seems that you use the method post
correctly. 查看您的JQuery代码,看来您正确使用了方法post
。 So I think that you should do the following things: 因此,我认为您应该执行以下操作:
Hope it helps you, Thierry 希望对您有帮助,蒂埃里
Use [ ] with params 与参数一起使用[]
$.post("https://api.twitch.tv/kraken/oauth2/token", {[
client_id: clientID,
client_secret: clientSecret,
grant_type: 'authorization_code',
redirect_uri: redirectURI,
code: user_code
]},
function(data) {
grabUserAccessTok(data);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.