有一种方法可以使用“.then回调”来console.log“青蛙”,因为我想在异步存储中看到我的令牌。
---在我获得令牌后,我需要将其附加在 fetch 调用的标头中,有人知道怎么做吗?
useEffect(() => {
const frog = AsyncStorage.getItem('AZURE-TOKEN');
console.log('THIS MY TOKEN', frog);
}, []);
Run Code Online (Sandbox Code Playgroud) 有办法识别设备类型(智能手机、平板电脑、笔记本电脑)吗?我需要将设备类型识别为:智能手机、平板电脑、笔记本电脑。我尝试使用“react-native-device-info” api 库,但不明白如何识别 3 种特定设备类型(智能手机、平板电脑、笔记本电脑) 。
那么我该如何做一些代码来告诉我如果它的“手机”=>智能手机,如果它的“未知”=>笔记本电脑/计算机,并且它也会保存在我的异步存储中。
import DeviceInfo from 'react-native-device-info';
import AsyncStorage from '@react-native-community/async-storage';
// how can i do some code that will gives me if its "Handset"=> Smartphone ,
//if its "unknown"=> Laptop/Computer
//and it will be saved as well in my async-storage.
//this some example that i wanna get it works well coz now its not work good
const funct1= (type) => {
let type = DeviceInfo.getDeviceType();
if type==='Handset'{
AsyncStorage.setItem('PLATFORM-TYPE', 'Smartphone');
}
if type==='unknown'{
AsyncStorage.setItem('PLATFORM-TYPE', 'Laptop/Computer'); …Run Code Online (Sandbox Code Playgroud)