Sansossio / twisted

Fetching riot games api data
125 stars 47 forks source link

MatchV5 list error #87

Closed Bruno-Marley closed 1 year ago

Bruno-Marley commented 1 year ago

Hello,

I had been looking for a updated npm package with matchv5, then I found this one but I'am getting an error trying to get List of Matches with There is my code:

    const riotClient = new LolApi({
        key: client.config.riotToken
    });

    let accinfo = await riotClient.Summoner.getByName("lontra23", Constants.Regions.EU_WEST);

    try {
        let info = await riotClient.MatchV5.list(accinfo.response.puuid, Constants.Regions.EU_WEST);

        console.log(info)
    } catch (error) {
        console.log(error)
    }

Error:

GenericError: Request failed with status code 400
    at MatchV5Api.getError (D:\GitHub\juninho\node_modules\twisted\dist\base\base.js:144:16)
    at MatchV5Api.<anonymous> (D:\GitHub\juninho\node_modules\twisted\dist\base\base.js:151:34)
    at Generator.next (<anonymous>)
    at D:\GitHub\juninho\node_modules\twisted\dist\base\base.js:27:71
    at new Promise (<anonymous>)
    at __awaiter (D:\GitHub\juninho\node_modules\twisted\dist\base\base.js:23:12)
    at MatchV5Api.retryRateLimit (D:\GitHub\juninho\node_modules\twisted\dist\base\base.js:150:16)
    at MatchV5Api.<anonymous> (D:\GitHub\juninho\node_modules\twisted\dist\base\base.js:233:35)
    at Generator.throw (<anonymous>)
    at rejected (D:\GitHub\juninho\node_modules\twisted\dist\base\base.js:25:65)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  status: 400,
  body: {
    status: {
      message: 'Bad request - Invalid routing value euw1',
      status_code: 400
    }
  },
  rateLimits: {
    Type: null,
    AppRateLimit: null,
    AppRateLimitCount: null,
    MethodRateLimit: undefined,
    MethodRatelimitCount: null,
    RetryAfter: 0,
    EdgeTraceId: 'a2323ee9-b65f-4a1b-8417-e9bb77a7e331'
  },
  error: Error: Request failed with status code 400
      at createError (D:\GitHub\juninho\node_modules\axios\lib\core\createError.js:16:15)
      at settle (D:\GitHub\juninho\node_modules\axios\lib\core\settle.js:17:12)
      at IncomingMessage.handleStreamEnd (D:\GitHub\juninho\node_modules\axios\lib\adapters\http.js:269:11)
      at IncomingMessage.emit (node:events:525:35)
      at endReadableNT (node:internal/streams/readable:1358:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21) {
    config: {
      url: 'https://euw1.api.riotgames.com/lol/match/v5/matches/by-puuid/u-D-96kgMtIEPmuI4onUDAPU07IjvNC5Zo-f6KXa3MUWqo4YmxU273rIpA_u0-2xy1AI8nC7dUnOYw/ids',
      method: 'get',
      headers: [Object],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      adapter: [Function: httpAdapter],
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      validateStatus: [Function: validateStatus],
      transitional: [Object],
      data: undefined
    },
    request: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: false,
      socket: [TLSSocket],
      _header: 'GET /lol/match/v5/matches/by-puuid/u-D-96kgMtIEPmuI4onUDAPU07IjvNC5Zo-f6KXa3MUWqo4YmxU273rIpA_u0-2xy1AI8nC7dUnOYw/ids HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Origin: null\r\n' +
        'X-Riot-Token: MY_API_TOKEN\r\n' +
        'User-Agent: axios/0.21.4\r\n' +
        'Host: euw1.api.riotgames.com\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      path: '/lol/match/v5/matches/by-puuid/u-D-96kgMtIEPmuI4onUDAPU07IjvNC5Zo-f6KXa3MUWqo4YmxU273rIpA_u0-2xy1AI8nC7dUnOYw/ids',
      _ended: true,
      res: [IncomingMessage],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'euw1.api.riotgames.com',
      protocol: 'https:',
      _redirectable: [Writable],
      [Symbol(kCapture)]: false,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(kUniqueHeaders)]: null
    },
    response: {
      status: 400,
      statusText: 'Bad Request',
      headers: [Object],
      config: [Object],
      request: [ClientRequest],
      data: [Object]
    },
    isAxiosError: true,
    toJSON: [Function: toJSON]
  }
}
Bruno-Marley commented 1 year ago

I found the error after reading the Riot Dev Docs Just need to replace Constants.Regions.EU_WEST to "EUROPE"

ciriousjoker commented 1 year ago

@Bruno-Marley Can you create a PR for this? I find this quite weird though, since I'm using this package in production and the match history v5 functionality works just fine for ppl on euw.