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