【发布时间】:2021-12-06 23:29:56
【问题描述】:
尝试使用以下方法访问 blob 存储 API,但得到 403 返回而没有错误抛出(发生这种情况是因为我试图访问不存在/没有权限的文件)。这种错误应该如何处理? .catch 已在调用 API 时应用。
背景.. 我试图故意犯错误,以便在 Azure blob 存储中获取文件。我确实期待 403,我希望妥善处理。
获取方法
getReq = async url => {
return new Promise((resolve, reject) => {
axios
.get(url)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
})
});
};
收到邮递员的回复
<?xml version="1.0" encoding="utf-8"?>
<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:maskedInfo
Time:maskedInfo</Message>
<AuthenticationErrorDetail>Signature did not match. String to sign used was
/blob/maskedInfo/maskedInfo/maskedInfo.json
ReadOnly
2020-08-04
b
</AuthenticationErrorDetail>
</Error>
试过了:
-
TryCatch也没有发现问题
【问题讨论】:
-
如何调用
getReq()方法? -
@BadPiggie 惯用的
asyncawait风格,不知道你想理解什么。 -
显示代码如何调用方法
getReq()
标签: javascript react-native azure-blob-storage