如何在节点 js 中获取异步存储的价值

时间:2021-01-10 16:17:34

标签: node.js react-native

我在 react-native 中使用异步存储保存了令牌。有什么办法可以在 Node.js 后端获取这个令牌值吗?

1 个答案:

答案 0 :(得分:0)

根据https://reactnative.dev/docs/asyncstorage,您可以从存储中获取该项目。您必须将其发布到后端可能使用 fetch

fetch('https://example.com/uploadtoken', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(TOKEN),
}).then(response => response.json()).then(data => {
  console.log('Success:', data);
}).catch((error) => {
  console.error('Error:', error);
});