将C#翻译为Javascript

时间:2017-11-23 01:35:53

标签: javascript c# axios

我正在为客户开发一个项目,需要将此api调用转换为Javascript。

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://stagingapi.asapconnected.com/api/login");

request.Headers.Add(HttpRequestHeader.Authorization, "user=username&organizationId=id&password=password&apiKey=apikey");

HttpWebResponse response = (HttpWebResponse)request.GetResponse()

string accessToken = response.Headers["asap_accesstoken"];

我的尝试转化为AXIOS获取请求:

axios({
  method: 'GET',
  url: 'https://api.asapconnected.com/api/login'
  headers: {
    'Authorization': 'user=org***&password=*******&organizationId=*****',
  }
}).then(res => {
  console.log(res);
}).catch(err => {
  console.log(err);
});

继续收到错误:

OPTIONS https://api.asapconnected.com/api/login net::ERR_CONNECTION_RESET

有什么建议吗?

0 个答案:

没有答案