question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Struggling with search

See original GitHub issue

Hi, I’m trying to use masto.js to search for toots and post some. I’m currently stuck at the search part, with different results (and errors) depending on the q parameter.

I initially wanted to find my own toots containing my site URL:

const dotenv = require("dotenv");
const { login } = require("masto");

dotenv.config();

const main = async () => {
  const MastodonClient = await login({
    url: process.env.MASTODON_INSTANCE,
    accessToken: process.env.MASTODON_ACCESS_TOKEN,
  });

  try {
    const search = await MastodonClient.search({
      type: "statuses",
      accountId: `${process.env.MASTODON_ID}`,
      q: "https://nicolas-hoizey.com/",
    });
    if (search) {
      for await (const statuses of search) {
        console.dir(statuses);
      }
    }
  } catch (error) {
    console.dir(error);
  }
};

main();

But I get this error:

Error [MastoUnprocessableEntityError]: Unprocessable Entity
    at MastoUnprocessableEntityError.MastoError [as constructor] (./node_modules/masto/dist/index.js:176:28)
    at new MastoUnprocessableEntityError (./node_modules/masto/dist/index.js:301:28)
    at createError (./node_modules/masto/dist/index.js:330:20)
    at HttpAxiosImpl.<anonymous> (./node_modules/masto/dist/index.js:2885:31)
    at step (./node_modules/masto/dist/index.js:103:23)
    at Object.throw (./node_modules/masto/dist/index.js:84:53)
    at rejected (./node_modules/masto/dist/index.js:75:65)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  statusCode: 422,
  description: 'No description provided for this error',
  details: undefined,
  isMastoError: true
}

I tried different values for the q parameter, with various results or error, and I don’t understand the logic, or what I’m doing wrong:

value of q result
"a-dumb-string-I-m-sure-it-will-not-find" Finds a lot of content but not containing this string
'"a-dumb-string-I-m-sure-it-will-not-find"' Error: Content-Type is not defined
'"adumbstringImsureitwillnotfind"' Error: Content-Type is not defined
"adumbstringImsureitwillnotfind" { accounts: [], statuses: [], hashtags: [] } 👍
"https://nicolas-hoizey.com/" Error [MastoUnprocessableEntityError]: Unprocessable Entity
`‘“https://nicolas-hoizey.com/”’ Error: Content-Type is not defined

Is there something I missed in the docs, that I should use to “prepare” the q value for these searches to work?

Thanks! 🙏

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nightpoolcommented, Nov 26, 2022

@nhoizey yes, because you’ve passed a full URL without indicating that you want to allow Mastodon to resolve this URL and make an authenticated HTTP Signatures request for it using your ID.

1reaction
github-actions[bot]commented, Nov 26, 2022

🎉 This issue has been resolved in version 4.6.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Struggling and Success in Web Search - ACM Digital Library
Web searchers sometimes struggle to find relevant information. Struggling leads to frustrating and dissatisfying search experiences, ...
Read more >
Job Search Depression Is Real: Here's How to Overcome It
The struggles of job hunting can leave you feeling rejected, stressed, anxious, and overall pessimistic about your future outlook. In a way, a ......
Read more >
Struggling and Success in Web Search | Request PDF
Web searchers sometimes struggle to find relevant information. Struggling leads to frustrating and dissatisfying search experiences, ...
Read more >
Are You Struggling with Job Search Anxiety? Here's How I ...
As someone who already struggles with generalized anxiety ... Here are 4 ways I've rebounded from my job search anxiety and depression:.
Read more >
Struggling and Success in Web Search - Susan Dumais
ABSTRACT. Web searchers sometimes struggle to find relevant information. Struggling leads to frustrating and dissatisfying search experiences,.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found