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,
};
since 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With