【发布时间】:2021-12-06 21:07:59
【问题描述】:
我正在尝试将此链接到单击我的 ReactJS 站点上的按钮。当我单击按钮时,我收到错误“uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')”
async function call () {
try {
axios({
method: 'post',
url: url,
header: {
"Content-Type": 'application/json',
"Authorization": `Bearer ${USER_KEY}`
},
data: {
prompt: script,
temperature: 0,
max_dist: 60,
stat_request: 1.0,
divider: ["\"\"\""]
}
}).then(
res => {
console.log(res.json())
}
);
} catch (error) {
return {statusCode: 500, body: error.toString()}
}
}
我正在尝试转换以下 curl 调用
curl https://myurlpath.com/test/call \
-H "Content-Type: application/json" \
-H "Authorization: Bearer USERS_KEY" \
-d '{
"prompt": "Please enter your thoughts:\n\"\"\"\nSome Generic paragraph.\n\"\"\"\n",
"temperature": 0,
"max_dist": 60,
"stat_request": 1.0,
"divider": ["\"\"\""]
}'
【问题讨论】:
标签: javascript reactjs curl axios