React native 如何在react native with Async Storage中重新设置本地存储会话

React native 如何在react native with Async Storage中重新设置本地存储会话,react-native,react-native-android,React Native,React Native Android,我正在使用异步存储来存储数据 我正在尝试使用异步存储设置新购物车列表,但设置的项目不是wokring 怎么可能再设置一次呢 CallPI(“POST”、url、addtoGrid、LoginUserID”、cart)。然后((response)=>response.json())。然后(responseJson=>{ //AsyncStorage.removeItem(“AddToCart”); if(responseJson.CartList.le) 请任何人都能帮我这会有用的 AsyncSt

我正在使用异步存储来存储数据 我正在尝试使用异步存储设置新购物车列表,但设置的项目不是wokring

怎么可能再设置一次呢

CallPI(“POST”、url、addtoGrid、LoginUserID”、cart)。然后((response)=>response.json())。然后(responseJson=>{ //AsyncStorage.removeItem(“AddToCart”); if(responseJson.CartList.le)

请任何人都能帮我这会有用的

AsyncStorage.setItem(“AddToCart”,responseJson.CartList);

只需同时使用
async/await
,如果
responseJson.CartList
不是字符串类型,则使用
JSON.stringify
进行转换

另外,不要忘记在使用
JSON.parse
AsyncStorage.getItem
过程中解析它

        this.setState({
          CartItem: responseJson.CartList,
          isLoading: false,
          TotalAmount: responseJson.TotalAmount
        })
        
           
          AsyncStorage.setItem("AddToCart", responseJson.CartList);
        
      
        this.props.navigation.dispatch(
          CommonActions.reset({
             
              routes: [
                  {
                      name: 'MyCart',
                  }
              ],
          })
      )
      })