【发布时间】:2021-02-14 10:47:03
【问题描述】:
并尝试获取 API 密钥。 该网站给了我一些卷曲代码。 好吧,因为我是韩国人,不确定我是否理解了描述。 总之,
curl --insecure -X POST
--header "Content-Type: application/x-www-form-urlencoded"
--header "Accept: application/json"
--data-urlencode "grant_type=urn:grant-type:apikey"
--data-urlencode "apikey=$API_KEY" "https://iam~~"
这是代码和 我想知道在 ajax 调用代码中将“--data-urlencode”部分放在哪里..
function to_ajax(){
$.getJSON("http://localhost~~/",
function(data){
$.ajax({
dataType: 'application/json',
data : {"grant_type":"urn:grant-type:apikey"
,"apikey=$API_KEY":"https://iam~~"},
headers: {"Content-Type" : "application/x-www-form-urlencoded" ,
"Accept": "application/json" } ,
success: function(msg) {
console.log(msg);
}
});
})
}
这就是我到达的地方......耻辱...... 当我运行它时,我得到了 CORS 错误。 IBM是这样解释的 'API 网关可以运行 API CORS 操作来处理 API 的跨域资源共享 (CORS) 请求。
默认情况下,API 禁用 CORS,在这种情况下,API 网关会将所有 CORS 请求传递到后端进行处理。当预检请求被传递到后端时,必须为每个可以成为请求目标的路径定义一个 OPTIONS 操作。否则,对该路径的预检请求可能会导致错误。'
所以这意味着他们允许所有访问权限,对吧?
【问题讨论】:
标签: javascript ajax curl