【问题标题】:How to store API endpoints in AsyncStorage如何在 AsyncStorage 中存储 API 端点
【发布时间】:2021-09-07 12:16:08
【问题描述】:

我们能否将 API ENDPOINT 存储在异步存储中并从中取回它们? 例如,我可以这样使用它吗?

const [socket, setSocket] = useState();

useEffect(()=>{
  const socket = io('url');
  setSocket(socket);
},[]);


const setSocket= async (value) => {
  try {
    await AsyncStorage.setItem('key', value)
  } catch(e) {
   console.log(e);
  }

  console.log('Done.')
}

【问题讨论】:

    标签: reactjs react-native websocket react-hooks asyncstorage


    【解决方案1】:

    异步存储不过是key value store,您可以像以前那样存储api端点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-18
      • 1970-01-01
      • 1970-01-01
      • 2016-01-01
      • 2020-03-09
      • 2017-09-11
      • 1970-01-01
      相关资源
      最近更新 更多