gpt4 book ai didi

react-native - 提供给 SecureStore 的值无效。值必须是字符串;如果它们是可序列化的,请考虑对您的值进行 JSON 编码

转载 作者:行者123 更新时间:2023-12-05 05:07:28 26 4
gpt4 key购买 nike

尝试将值存储到 expo SecureStore 但出现此错误

Invalid value provided to SecureStore. Values must be strings; consider JSON-encoding your values if they are serializable.
- node_modules\expo-secure-store\build\SecureStore.js:25:14 in setItemAsync$
- node_modules\regenerator-runtime\runtime.js:45:44 in tryCatch
- node_modules\regenerator-runtime\runtime.js:271:30 in invoke
- node_modules\regenerator-runtime\runtime.js:45:44 in tryCatch
- node_modules\regenerator-runtime\runtime.js:135:28 in invoke
- node_modules\regenerator-runtime\runtime.js:170:17 in <unknown>
- node_modules\promise\setimmediate\core.js:45:7 in tryCallTwo
- node_modules\promise\setimmediate\core.js:200:23 in doResolve
- node_modules\promise\setimmediate\core.js:66:12 in Promise
- node_modules\regenerator-runtime\runtime.js:169:27 in callInvokeWithMethodAndArg
- node_modules\regenerator-runtime\runtime.js:192:38 in enqueue
- node_modules\regenerator-runtime\runtime.js:216:8 in <unknown>
- node_modules\expo-secure-store\build\SecureStore.js:22:7 in setItemAsync
* src\context\AuthContext.js:32:37 in _callee$
- node_modules\regenerator-runtime\runtime.js:45:44 in tryCatch
- node_modules\regenerator-runtime\runtime.js:271:30 in invoke
- ... 13 more stack frames from framework internals

这是我正在尝试的代码...

await SecureStore.setItemAsync('email',response.data.email);

最佳答案

转换必须在发送 friend 变量之前完成,即使是 JSON(),它也遵循它的样子

await SecureStore.setItemAsync('email',JSON.stringify(response.data.email));

关于react-native - 提供给 SecureStore 的值无效。值必须是字符串;如果它们是可序列化的,请考虑对您的值进行 JSON 编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59136396/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com