0
내 코드는 다음과 같습니다. I는 정의는 (') _this.storeAPIToken (responseJson.APIToken'평가) 함수 오류없는 얻을undefined is not a function 네이티브 반응
async function storeAPIToken(APIToken) {
try {
await AsyncStorage.setItem('@auth:APIToken', APIToken);
} catch (error) {
console.log("STORE API", error);
}
}
const verifyOTPResponse = (dispatch, responseJson) => {
console.log("checkOTPAPIStatus", responseJson.status);
if (responseJson.status == "OK") {
console.log("verifyOTPEntered OK");
console.log('Token', responseJson.APIToken);
this.storeAPIToken(responseJson.APIToken);
firebase.auth().signInWithCustomToken(responseJson.token).then(() => {
console.log("Login successfulx");
dispatch({
type: types.LOGIN_SUCCESS,
payload: 1
});
}).catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
dispatch({
type: types.LOGIN_FAIL,
payload: 0
});
});
} else {
dispatch({
type: types.OTP_VERIFICATION_FAIL,
payload: loginStatus
});
responseJson.APIToken는 I 콘솔 그것을
오류는 '_this.storeAPIToken'에 있습니다. – Dekel
'verifyOTPResponse'에는'storeAPIToken' 기능이 없습니다. 'this '를 사용하는 것은 잘못된 것입니다. 'this'를 제거하고 다시 시도하십시오 – bennygenel
오류가'this.storeAPIToken'이'undefined '라는 사실을 언급하고있는 것 같습니다 - 아마도이 함수를 호출 할 때'this.'는 필요 없습니다. –