【问题标题】:React Native Axios JavaScript how to pass an array of strings as params in GET requrestReact Native Axios JavaScript如何在GET请求中将字符串数组作为参数传递
【发布时间】:2021-06-22 00:40:06
【问题描述】:

我正在使用 Axios 进行 API 调用,我需要在 GET Request 中发送一个字符串数组我如何在参数中添加我的列表(在 URL 中)

【问题讨论】:

    标签: javascript react-native api get axios


    【解决方案1】:

    这可能会有所帮助

    import axios from 'axios';
    
    axios.get('/api', {
        params: {
          data: JSON.stringify(data)
        }
      })
      .then(function (response) {
        console.log(response);
      })
    

    【讨论】:

    • 或者const response = await axios.get('/api', { ... });
    猜你喜欢
    • 1970-01-01
    • 2019-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-21
    • 2022-11-20
    • 1970-01-01
    相关资源
    最近更新 更多