aws amplify custom headers : 属性 预期分配
aws amplify custom headers : Property Assignment Expected
当我添加此代码进行反应时,错误似乎是无法识别 await。准确的错误是 属性 Assignment Expected at the 'await' word
我正在阅读 aws-amplify 中关于自定义 headers https://aws.github.io/aws-amplify/media/api_guide#custom-request-headers 的文档。
这是来自 index.js 的代码(其中配置了放大)
aws_exports.API = {
endpoints:[
{
name: "my_custom_api",
endpoint: "http://localhost:57200/",
custom_header: async() => {
return { (await Auth.currentSession()).idToken.jwtToken }
}
}
]
}
Amplify.configure(aws_exports);
文档中似乎有错字。 return { (await Auth.currentSession()).idToken.jwtToken }
是无效语法,但如果将该值分配给 Authorization
键,它应该可以工作:
async () => {
return { Authorization: (await Auth.currentSession()).idToken.jwtToken };
}
当我添加此代码进行反应时,错误似乎是无法识别 await。准确的错误是 属性 Assignment Expected at the 'await' word
我正在阅读 aws-amplify 中关于自定义 headers https://aws.github.io/aws-amplify/media/api_guide#custom-request-headers 的文档。
这是来自 index.js 的代码(其中配置了放大)
aws_exports.API = {
endpoints:[
{
name: "my_custom_api",
endpoint: "http://localhost:57200/",
custom_header: async() => {
return { (await Auth.currentSession()).idToken.jwtToken }
}
}
]
}
Amplify.configure(aws_exports);
文档中似乎有错字。 return { (await Auth.currentSession()).idToken.jwtToken }
是无效语法,但如果将该值分配给 Authorization
键,它应该可以工作:
async () => {
return { Authorization: (await Auth.currentSession()).idToken.jwtToken };
}