因此,我试图将我的应用程序连接到我的AWS S3存储桶,而我尝试使用的代码对其他人有效,但对我却不起作用。对于我的应用程序,最佳方法是什么?
这是我尝试使用的代码:
由于某种原因,我的UpdateBucket()调用给我错误。
async UpdateBucket() {
let bucketDataUpdate = JSON.stringify(this.state);
const Url = "my url";
const FetchData = {
method: "PUT",
mode: "cors",
cache: "no-cache",
credentials: "omit",
headers: { "Content-Type": "application/json" },
body: bucketDataUpdate
};
await fetch(Url, FetchData)
// .then(res => res.json())
.then(data => console.log(data))
.catch(err => console.log(err));
}
是否缺少function
关键字?
async function UpdateBucket() {
let bucketDataUpdate = JSON.stringify(this.state);
const Url = "my url";
const FetchData = {
method: "PUT",
mode: "cors",
cache: "no-cache",
credentials: "omit",
headers: { "Content-Type": "application/json" },
body: bucketDataUpdate
};
await fetch(Url, FetchData)
// .then(res => res.json())
.then(data => console.log(data))
.catch(err => console.log(err));
}
或者是class
的代码部分?