【发布时间】:2018-09-28 23:14:50
【问题描述】:
我想知道是否可以从第二次或第三次通话中删除一些等待。
async componentDidMount() {
try {
let response = await this.CollectionManager.GetAllCollections();
if(!response.error) {
this.setState({collections: response.data});
}
} catch (e) {
this.notify("Error can't connect with the server.");
}
}
async GetAllCollections() {
try {
return await this.httpClient.Get(this.api_url);
} catch (e) {
}
}
async Get (url) {
try {
return this.Response(await Axios.get(this._apiUrl + url));
} catch (e) {
}
}
我无法在互联网上找到更多示例。
【问题讨论】:
-
这取决于代码是否需要等待。这种“感觉”适合您的情况吗?
-
因此,如果我删除指令二或三的等待,它会返回相同的结果吗?永不失败?
-
不,它会失败。