admin管理员组文章数量:1253715
The react-native project I'm working on already use react-native-device-info. When I tried to add Android-${DeviceInfo.getUniqueID()}
to a header in a request, I get this error:
{ TypeError: DeviceInfo.getUniqueID is not a function
at makeRequest (~/code/rn/src/services/api-client.js:46:39)
How can that be? I import it like this on the top of the files it is used in.
import * as DeviceInfo from 'react-native-device-info';
If I change the import statement to import DeviceInfo from 'react-native-device-info';
, then I get this error:
TypeError: _reactNativeDeviceInfo2.default.getUniqueID is not a function
export function makeRequest(endpoint, method, token, csrfToken = null, body = null) {
const config = {
method,
credentials: 'same-origin',
headers: {
Applikasjon: 'KONSERNAPP',
Accept: 'application/json',
'X-App-Version': `Android-${DeviceInfo.getUniqueID()}`,
'Content-Type': 'application/json',
token,
},
timeout: 120000,
};
The react-native project I'm working on already use react-native-device-info. When I tried to add Android-${DeviceInfo.getUniqueID()}
to a header in a request, I get this error:
{ TypeError: DeviceInfo.getUniqueID is not a function
at makeRequest (~/code/rn/src/services/api-client.js:46:39)
How can that be? I import it like this on the top of the files it is used in.
import * as DeviceInfo from 'react-native-device-info';
If I change the import statement to import DeviceInfo from 'react-native-device-info';
, then I get this error:
TypeError: _reactNativeDeviceInfo2.default.getUniqueID is not a function
export function makeRequest(endpoint, method, token, csrfToken = null, body = null) {
const config = {
method,
credentials: 'same-origin',
headers: {
Applikasjon: 'KONSERNAPP',
Accept: 'application/json',
'X-App-Version': `Android-${DeviceInfo.getUniqueID()}`,
'Content-Type': 'application/json',
token,
},
timeout: 120000,
};
Share
Improve this question
edited Oct 16, 2018 at 9:18
David Schumann
14.8k13 gold badges83 silver badges105 bronze badges
asked Oct 19, 2017 at 13:08
martinsmartins
10k12 gold badges64 silver badges88 bronze badges
4
- have you solved this issue in the meantime? – David Schumann Commented Oct 16, 2018 at 9:18
- I can't really remember. I think I solved it in a hackish workaround. – martins Commented Oct 16, 2018 at 11:16
-
2
If you encounter anything like that in version
3.0.0
, try to revert to2.3.2
. – Jonas Sourlier Commented Sep 12, 2019 at 18:44 -
1
same problem when updated today,
yarn add [email protected]
to downgrade – Jose V Commented Sep 13, 2019 at 21:44
3 Answers
Reset to default 8since react-native-device-info is upgraded to 4.x.x
its method typo is bit changed, it is now accepting DeviceInfo.getUniqueId()
instead of DeviceInfo.getUniqueID()
This solved it for me
DeviceInfo.getUniqueId()
instead of
DeviceInfo.getUniqueID()
.
Lolz. It's a typo in the documentation
Downgrading:
-> yarn add [email protected]
then use DeviceInfo.getUniqueID()
Working for me.
本文标签: javascriptDeviceInfogetUniqueID is not a functionStack Overflow
版权声明:本文标题:javascript - DeviceInfo.getUniqueID is not a function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740777749a2284566.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论