请求中编码的请求表单URL

时间:2020-10-22 22:53:39

标签: node.js reactjs express

我正在尝试在请求时发出请求form_url_encoded,但是这给我已经在端口3000上的控制台提供了一个错误,它给了一些错误但没有找到它,因为如果我保留默认设置文档,它运行正常并在门口打开。我得到:

错误:连接ECONNREFUSED

const express = require("express");
const router = express.Router();
const axios = require("axios");
const qs = require("qs");

const requestBody = {
  refresh_token:
    "1000.51355b1f8f5a8176026525670b5bbf3e.93c56a6bd3cb4589bd65b334810848cf",
  client_id: "1000.KS2QNMSAQIMS74YBGZROSXD8QD3GWO",
  client_secret: "06abfcc05409c430fb15252d47e8d9fe03a3582cbc",
  rant_type: "refresh_token",
};

const config = {
  headers: {
    "Content-Type": "application/x-www-form-urlencoded",
  },
};

const config2 = {
  headers: {
    "Content-Type": "application/json",
  },
};

axios
.post(
  "/crm7/sell_order",
  { test: "test" },
  config2
)
.then((res) => {
  console.log(res);
  return  axios.post("https://accounts.blue.com/oauth/v2/token", qs.stringify(requestBody), config);
})
.then((res) => {
   console.log(res)
})
.catch((err) => {
  console.log(err)
});

module.exports = router;

0 个答案:

没有答案