Reactjs 如何使用Axios将对象作为查询字符串传递给web api

Reactjs 如何使用Axios将对象作为查询字符串传递给web api,reactjs,axios,Reactjs,Axios,我是Axios的新手,在这个简单的问题上有问题 我的反应代码: const params = { "id": "1", "name":"Mike" }; axios.request({ url: 'https://localhost:44343/api/SampleData/test', method: 'get', data:params })

我是Axios的新手,在这个简单的问题上有问题

我的反应代码:

const params = {
      "id": "1",
      "name":"Mike"
  };
  axios.request({
      url: 'https://localhost:44343/api/SampleData/test',
      method: 'get',
      data:params
  })
我的asp.net核心web api:

[HttpGet("test")]
public async Task Test([FromQuery]Model model)
我的模型:

public class Model
    {
        public string Id { get; set; }
        public string Name { get; set; }
    }
我未能将js对象作为查询字符串传递给api代码<对于
Id
Name
model
数据为空,我找到了解决方案:

const querystring = require('querystring');

  const params = {
      "id": "1",
      "name":"Mike"
  };
  axios.request({
      url: 'https://localhost:44343/api/SampleData/test?' + querystring.stringify(params),
      method: 'get',
      data:params
  })

您收到的错误是什么没有错误,
model