【问题标题】:Use https module in react native在本机反应中使用 https 模块
【发布时间】:2021-02-19 08:33:52
【问题描述】:

我想在 react native 中使用 nodejs 的 https 标准库模块(我需要 https.Agent for axios)。有没有合适的方法来做到这一点?

【问题讨论】:

    标签: javascript android node.js react-native


    【解决方案1】:

    也可以使用 JavaScipt 的内置函数 'fetch' 来执行。

    例子:

    fetch('https://mywebsite.com/endpoint/', {
      method: 'POST',
      headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        firstParam: 'yourValue',
        secondParam: 'yourOtherValue'
      })
    });
    

    更多:https://reactnative.dev/docs/network

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-24
    • 2020-05-22
    • 2018-05-28
    • 2016-02-03
    • 2018-08-02
    相关资源
    最近更新 更多