javascript - 400 Bad Request 使用 Axios 获取请求
问题描述
我正在阅读请求方法别名
axios.get(url[, config])
我试着做方法
const axios = require('axios')
let data = new Date()
let timer = date.getTime()
const config = {
'kc-api-key': 'xxxxxxxxxxxx', // primary key
'kc-api-sign': 'xxxxxxxxxxx', // screat key
'kc-api-timestamp' : timer, // timestamp
'kc-api-passpharase : 'xxxxxxx ' // passpharase
axios.get('https://api.kucoin.com/api/v1/accounts/',config)
.then(r => {
console.log('Ok')
})
.catch(e => {
console.log('Error')
})
return 400 Bad Request -- 无效的请求格式现在我不知道如何解决它。
消息:“请求失败,状态码 400”
解决方案
我很确定这是定义标题的方法:
const config = {
headers: {
'kc-api-key': 'xxxxxxxxxxxx', // primary key
'kc-api-sign': 'xxxxxxxxxxx', // screat key
'kc-api-timestamp' : timer, // timestamp
'kc-api-passpharase : 'xxxxxxx ' // passpharase
}
}
axios.get('https://api.kucoin.com/api/v1/accounts', config)
推荐阅读
- java - 在linux中解压gzip文件时出错
- php - Elfinder 添加了错误的路径来浏览字段
- java - 如何从两个编辑文本中获取所选数字值的总和
- haskell - 如何在 TemplateHaskell 模型文件中使用自定义 PersistField?
- javascript - 如何确保我的 e2e 测试执行正确?
- java - HTTP 状态 405 - @DELETE 方法上不允许的方法
- python - Python - Gmail API - “资源”实例没有“用户”成员
- python - PYTHON 如何制作“关联数组”
- javascript - 如何在具有NULL值的angularjs中实现Excel Like Filter?
- android - Kotlin - 通过 Intent 将函数作为参数传递