我打電話這段代碼:異步調用返回的功能與數字無極對象屬性名稱
Permissions.check('photo')
.then(response => {
...
});
在這裏,我可以使用response對象來檢查值。
但是我想叫這個的await這樣的:
async function test() {
let test = await Permissions.check('photo');
return test;
}
...
let result = test();
但這返回我看起來像這樣的承諾對象:
Promise {_40: 0, _65: 0, _55: null, _72: null}
和價值,我通常在response
這裏我result._55
得到得到。
我能做些什麼來獲得正確的對象?
如果結合'await'和'then',它會起作用。但我認爲這是一個不好的做法。嘗試'讓測試;等待Permissions.check('photo')。然後((response)=> test = response);' –
我之前問過類似的問題,這裏有一個非常有用的信息在接受的答案:https://stackoverflow.com/問題/ 45765114/how-to-a-function-or-a-database-query-and-then-process-results-and-fi –