Skip to content

prepareAuth errors with multiple requests #102

@kanadgupta

Description

@kanadgupta

I'm seeing an error when making multiple authenticated requests as shown below:

const sdk = require('api')('https://docs.readme.com/developers/openapi/5e1a4f6284248b0018149174');

async function run() {
  const changelogs = await sdk.auth('API_KEY').getChangelogs()
    .then(res => res.json())
    .then(res => {
      return res;
    });

  return sdk.auth('API_KEY').getChangelog({ slug: changelogs[0].slug })
    .then(res => res.json())
    .then(res => {
      console.log(res);
    });
}

run();

I get this error:

TypeError: Cannot read property 'length' of undefined
    at authKeys.forEach (code/node_modules/api/src/lib/prepareAuth.js:21:17)
    at Array.forEach (<anonymous>)
    at module.exports (code/node_modules/api/src/lib/prepareAuth.js:19:12)
    at fetchOperation (code/node_modules/api/src/index.js:37:87)
    at Object.assign.args (code/node_modules/api/src/index.js:63:22)
    at Proxy.<anonymous> (code/node_modules/api/src/index.js:117:33)
    at run (code/index.js:10:55)

For some reason, it's having trouble loading securitySchemes here:

if (schemes.length > 1) {

Metadata

Metadata

Assignees

Labels

area:coreIssues related to `core`, which is the package that powers the SDKs at runtimebugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions