API Browser autocomplete is broken

When I try to use the API Browser for a repository I've created:
https://fsdm-test.prismic.io/api/v2
If I press ctrl+space to try to bring up auto-completion suggestions, I get this error in the console:

api.min.js:26 Uncaught TypeError: CodeMirror.showHint is not a function
    at CodeMirror.commands.autocomplete (api.min.js:26)

I couldn't find any other mention of it on the forum, so maybe it only affects my repo? Any idea how to get it working?

2 Likes

Hello Duncan M, thanks for informing us about this. I will pass this message on to the dev team. When we have more information or a definitive solution for this issue, we'll let you know.

Thanks

This thread is being monitored as an open ticket in the issue tracker. We will update this post as we get more information. If you have a similar use-case, you can ‘Flag’ this topic to reopen.

I'm having the same issue, how am I supposed to know what fields I can and can't query in the API browser with autocomplete being broken? This forces me to guess what fields I can query.

I'm new to Prismic and all I want to do is query based on a field called game_name, but without autocomplete I can't figure out how to do that.

If I query [at(document.type, "_generic_game_template")] then I get JSON results like this:

"results": [
-{
"id": "REDACTED",
"uid": null,
"url": null,
"type": "_generic_game_template",
"href": "REDACTED",
"tags": [ ],
"first_publication_date": "2022-02-14T15:00:54+0000",
"last_publication_date": "2022-03-29T13:51:50+0000",
-"slugs": [
"capital-gains"
],
"linked_documents": [ ],
"lang": "en-us",
"alternate_languages": [ ],
-"data": {
"game_name": "Capital Gains",
"game_launch_id": "5134",
"game_type_id": "4644",
"game_type_id_mobile": "4644",
"provider": null,
"device_restriction": "desktop mobile",
"os_restriction": "ios android",
+"games_filter": [ … ],
+"game_thumbnail": { … },
+"latest_played_thumbnail": { … },
+"vertical_thumbnail": { … },
+"app_thumb": { … },
"holiday_icon": { },
"xppoints": null,
"gameinfotext": [ ],
"qa_desktop_allowed": true,
"qa_mobile_browser_allowed": true,
"qa_android_app_allowed": true,
"qa_ios_app_allowed": true,
"live_desktop_allowed": true,
"live_mobile_browser_allowed": true,
"live_android_app_allowed": true,
"live_ios_app_allowed": true
}
},

Since there is a data object with game_name inside of it I would expect this to work:

at(document.data.game_name, "Capital Gains")

But I get this error in the photo attached:

And without autocomplete I see no way of knowing how to do the query properly. Has there been any movement on fixing this?

Did someone forget to "import "codemirror/addon/hint/show-hint.js"; somewhere?

Hello @web2

We are aware of the autocomplete issue with the API Browser. Our team is working on it and will release a fix for it. But I don't have an ETA at the moment.

To answer your questions, you want to retrieve a specific field. You need to use fetch parameter as a search parameter reference in the query string only to retrieve the specified field. Learn more about the Search parameter reference.

Let me know if you have any further questions related to it.

Thanks,
Priyanka

Hi Priyanka,

Great, the fetch parameter is helpful in cutting down on unnecessary data being returned, thanks!

On this repository, https://wynncasino.prismic.io/ how do I write a query in the API browser that returns all documents of type "game" with the "game_name" equal to "Capital Gains"? I thought something like at(document.data.game_name, "Capital Gains") would work, but I get the error mentioned above. It seems like this should be really simple, but without autocomplete I'm a bit lost.

Thanks,
Eddie

Hello @busted_github_sso

To check if a string is available inside a whole document or within a specific field on a document, you need to use fulltext. In your particular case, apply this query in the API browser:

[fulltext( my.game.game_name, "Capital Gains" )]

The API will return all game documents that contain Capital Gains term.

Let me know if you have any further questions.

Thanks,
Priyanka

Awesome, thanks Priyanka!

Best,
Eddie

You are welcome @web2. Feel free to reach out to us if you have any questions.