簡體   English   中英

400 Bad Request 使用 Axios 獲取請求

[英]400 Bad Request using Axios get request

我正在讀取請求方法別名

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')
  })

返回 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)

在您的配置變量中,確保將您的密鑰用雙引號括起來。

JSON 中的屬性必須是用雙引號括起來的字符串。 換句話說,不允許使用單引號或根本不使用引號。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM