javascript - 当我与比特币平均服务器通信时,它显示 403 状态代码错误

标签 javascript node.js express

const express = require("express");
const bodyParser = require("body-parser");
const request = require("request");
const app = express();

app.use(bodyParser.urlencoded({extended: true}));

app.get("/", function(req, res){
  res.sendFile(__dirname + "/index.html");
});

app.post("/", function(req, res){
request(" https://apiv2.bitcoinaverage.com/indices/global/ticker/all?crypto=BTC&fiat=USD,EUR", function(error, response, body){
console.log(response.statusCode);
});

});

app.listen(3000, function(){
  console.log("server is running in port 3000");
});

当我与比特币平均服务器通信时,它显示 403 状态代码错误。

最佳答案

如果您看到响应正文console.log(response.body);请查看此错误并

Unauthenticated requests can't access endpoint apiv2.bitcoinaverage.com/indices/global/ticker/all?crypto=BTC&fiat=USD,EUR

403 代表 unauthorized (“拒绝授权”);即“我知道您是谁,但您无权访问此资源。”

403 Forbidden

The 403 (Forbidden) status code indicates that the server understood the request but refuses to authorize it. A server that wishes to make public why the request has been forbidden can describe that reason in the response payload (if any).

If authentication credentials were provided in the request, the server considers them insufficient to grant access. The client SHOULD NOT automatically repeat the request with the same credentials. The client MAY repeat the request with new or different credentials. However, a request might be forbidden for reasons unrelated to the credentials.

An origin server that wishes to "hide" the current existence of a forbidden target resource MAY instead respond with a status code of 404 (Not Found).

你应该Making Authenticated Requests

关于javascript - 当我与比特币平均服务器通信时,它显示 403 状态代码错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58245565/

相关文章:

javascript - 如何召回或重启 MathJax?

javascript - API 17 : Action Bar implemented but not appear - Android Studio

node.js - 将对象数组发布到 sails 导致 'TypeError: Cannot convert object to primitive value'

javascript - 复制数组的内存有效方法

node.js - 在 koa 中使用 express 中间件

javascript - 防止页面在检查输入时突然跳动

javascript - Form.submit 在 FF 和 IE 中不起作用

javascript - 需要原型(prototype)内部或外部的功能?

html - 如何根据node.js express中的特定按钮调用函数

reactjs - 将 CRA 部署到 s3 并使用 Express 提供服务