javascript - 使用 JavaScript 和 Angular (HttpClient) 进行 FPL Api 身份验证

标签 javascript angular api xmlhttprequest

我正在尝试使用 FPL api 进行身份验证 谁能帮我解决以下问题,我找不到问题所在

这是身份验证指南 https://medium.com/@bram.vanherle1/fantasy-premier-league-api-authentication-guide-2f7aeb2382e4

我收到此错误

status: 200

statusText: "OK"

url: "https://cors-anywhere.herokuapp.com/https://users.premierleague.com/accounts/login/"

ok: false

name: "HttpErrorResponse"

message: "Http failure during parsing for https://cors-anywhere.herokuapp.com/https://users.premierleague.com/accounts/login/"


import { HttpClient } from '@angular/common/http';




constructor(private http: HttpClient) {}



getData() {


    const proxy = 'https://cors-anywhere.herokuapp.com/';

    this.http
      .post(${proxy}https://users.premierleague.com/accounts/login/,
   {
      redirect_uri: 'https://fantasy.premierleague.com/a/login',
      app: 'plfpl-web',
      login: 'my-email',
      password: 'may-pass'
    }
)
      .subscribe((data) => {
        console.log(data);
      });
  }
}

最佳答案

如果您访问为请求指定的 URL,它会告诉您问题到底是什么:

Missing required request header. Must specify one of: origin,x-requested-with

关于javascript - 使用 JavaScript 和 Angular (HttpClient) 进行 FPL Api 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59384373/

相关文章:

javascript - jquery中长轮询的有效方法

javascript - Vue 路由器不加载组件

android - 将 .ics 文件恢复到 Android 手机日历中

javascript - 为 php 中的特定 get 请求执行 javascript

javascript - 在 jsrender 中使用脚本

angular - date.getDate 不是函数 Typescript

angular - 如何从组件获取服务中 Observable 的值并将其传递到我的 View ?

angular - 在 NgRx 中强类型化存储的目的是什么?

api - 如何从 Yelp API 请求更大的图像?

api - 在本地主机上测试 foursquare API