मेरे पास कोड का यह टुकड़ा है
<GoogleLogin
onSuccess={responseGoogle => {
const { email, name } = responseGoogle.profileObj; // error: Property 'profileObj' does not exist on type 'GoogleLoginResponse | GoogleLoginResponseOffline'.
}}
/>
लाइब्रेरी यहां है https://www.npmjs.com/package/react-google- लॉगिन करें
मुझे क्या करना चाहिए? मैंने कोशिश की (प्रतिक्रिया Google: कोई भी) यह काम नहीं करता है।
0
Mellisa Lee
18 फरवरी 2020, 08:59
3 जवाब
आपको लॉगिन प्रतिक्रिया प्रकार निर्दिष्ट करना होगा। यह या तो GoogleLoginResponseOffline
या GoogleLoginResponse
हो सकता है। संपत्ति profileObj
केवल GoogleLoginResponse
में मौजूद है। यदि आप ऑफ़लाइन पहुंच का अनुरोध कर रहे हैं, तो प्रतिसाद में केवल code
होगा और आपको GoogleLoginResponseOffline
प्रकार का उपयोग करना चाहिए।
<GoogleLogin
onSuccess={(responseGoogle: GoogleLoginResponse) => {
const { email, name } = responseGoogle.profileObj;
}}
/>
0
MjZac
18 फरवरी 2020, 09:19
ये कोशिश करें
<GoogleLogin
onSuccess={(responseGoogle: GoogleLoginResponse ) => {
const { email, name } = responseGoogle.profileObj
}}
/>
या आप टाइपस्क्रिप्ट को यह बताने के लिए के रूप में कीवर्ड का भी उपयोग कर सकते हैं कि यह GoogleLoginResponse
प्रकार का है और इसे GoogleLoginResponseOffline
के रूप में गलत व्याख्या नहीं करना चाहिए।
0
code it up
18 फरवरी 2020, 09:34
ये कोशिश करें
<GoogleLogin
onSuccess={({ profileObj: { email, name } = {} }: any) => {
// use email and name
}
/>
-1
Siva K V
18 फरवरी 2020, 09:17
Cannot find name 'GoogleLoginResponse'
की त्रुटि मिलीimport { GoogleLoginResponse } from 'react-google-login';
जोड़ना होगा