Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating search from string doesn't work #642

Open
Heath123 opened this issue Feb 13, 2021 · 5 comments
Open

Creating search from string doesn't work #642

Heath123 opened this issue Feb 13, 2021 · 5 comments

Comments

@Heath123
Copy link

Trying to use the function http://github-tools.github.io/github/docs/3.2.3/GitHub.html#search (using 3.4.0 but the docs aren't up for that) like this:

console.log(gh.search('query'))

gives this error:

/home/heath/SyncedProjects/CredentialReminderBot/node_modules/github-api/dist/components/Requestable.js:162
            requestOptions.type = requestOptions.type || 'all';
                                ^

TypeError: Cannot create property 'type' on string 'query'
    at Search._getOptionsWithDefaults (/home/heath/SyncedProjects/CredentialReminderBot/node_modules/github-api/dist/components/Requestable.js:162:33)
    at new Search (/home/heath/SyncedProjects/CredentialReminderBot/node_modules/github-api/dist/components/Search.js:46:30)
    at GitHub.search (/home/heath/SyncedProjects/CredentialReminderBot/node_modules/github-api/dist/components/GitHub.js:159:14)
    at Object.<anonymous> (/home/heath/SyncedProjects/CredentialReminderBot/index.js:11:16)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
@Heath123 Heath123 changed the title CReating search from string doesn't work Creating search from string doesn't work Feb 13, 2021
@Heath123
Copy link
Author

Looks like it actually needs this, not a string:
@param {Object} [requestOptions={}] - the current options for the request

@Heath123
Copy link
Author

There's also no forCommits on the class

@Heath123
Copy link
Author

Heath123 commented Feb 13, 2021

data: {
      message: "If you would like to help us test the Commit Search API during its preview period, you must specify a custom media type in the 'Accept' header. Please see the docs for full details.",
      documentation_url: 'https://docs.github.com/rest/reference/search#search-commits'
}

Huh, I guess I'll have to do that part manually?

@Heath123
Copy link
Author

data: {
      message: "API rate limit exceeded for 95.111.249.143. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
      documentation_url: 'https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting'
}

Is this my fault or is auth broken?

@Heath123
Copy link
Author

Heath123 commented Feb 13, 2021

const search = gh.search({})
search.__AcceptHeader = 'cloak-preview'
search._search('commits', { q: 'query' }, (err, result) => { console.log(err, result) })

This seems to work

@Heath123 Heath123 reopened this Feb 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant