masto.js icon indicating copy to clipboard operation
masto.js copied to clipboard

No result provided from search() method

Open Booteille opened this issue 2 years ago • 2 comments

Hi.

I am trying to get results from masto.search() but I get no result under accounts/hashtags/statuses returned by the function.

Here is the code:

const r = await masto.search({
    q: "booteille"
  }).next()

  if (r) {
    console.log(r.done)
    console.log(r.value)
  }

Here are console logs:

false
Object { accounts: [], statuses: [], hashtags: [] }

Did I do something wrong? I tried with 3 different keywords, I have results for each with the user logged in on Mastodon interface. App has global read permissions.

Thanks.

Booteille avatar Jun 21 '22 13:06 Booteille

Thank you for reporting the issue. Unfortunately, the code you provided has worked without any problem on my instance.

Firstly, could you try the exact same keyword in the Web interface and verify with a network inspector that the request to /api/v2/search returns the results you expect? The masto.search method corresponds to the search bar in the very left column.

image

Also, I'm not very familiar with how WebFinger works, but since Web UI always specifies resolve param described in this page, adding resolve: true would also help you get the same result as the Web UI.

const r = await masto.search({
    q: "booteille"
+    resolve: true
  }).next()

neet avatar Jun 21 '22 14:06 neet

Hi!

Thanks for your fast answer.

Unfortunately, using resolve did not work neither. The API does not seem to return wanted results.

Capture d’écran du 2022-06-22 14-32-23

After investigating, I found the request does not seem to contain the q parameter (neither the resolve one, when I add it).

Editing through Firefox dev tools the request to add the parameter returns results as intented.

Any idea why it's not working on my case?

Booteille avatar Jun 22 '22 12:06 Booteille

I believe this issue is fixed by #700. If you think you still have a problem, feel free to reopen it.

neet avatar Nov 28 '22 04:11 neet