React native 使用encodeURIComponent值响应本机获取post

React native 使用encodeURIComponent值响应本机获取post,react-native,React Native,我要用fetch来邮寄 const token = 'ABCD123:A' await fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: token=encodeURIComponent(token), }); encodeURIComponent(令牌)应为ABCD123%3AA 我的服务器应该得到编码值

我要用fetch来邮寄

const token = 'ABCD123:A'
await fetch(path, {
   method: 'POST',
   headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
   },
   body: token=encodeURIComponent(token),
});
encodeURIComponent(令牌)应为
ABCD123%3AA

我的服务器应该得到编码值,解码值,然后存储到数据库。 但在我的api服务器中,它获取非编码体:
token=ABCD123:A

服务器应该获取编码值吗

我在Postman上测试了相同的编码值,我的服务器得到了编码值


由于我的服务器得到不同的值,是Fetch API问题还是我的Fetch请求问题?

我想您忘记为Body创建
对象了

const token = 'ABCD123:A'
await fetch(path, {
   method: 'POST',
   headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
   },
   body: {
           'token':encodeURIComponent(token)
         }

});

如果这也不起作用,那么在fetch外部编码并记录该值,看看它是否被编码?在传递到fetch之前,我已经记录了该值,它被编码了。但服务器正在进行非编码。如果我将对象传递到body中,它会抛出
不支持的BodyInit type
错误…“Content-type”:“application/json”,您可以将其更改为发送对象