Timeout support

Hi :wave:, I noticed on the release notes that there was support for a timeout now in prismic-javascript v2.6.0 and up. I couldn't find any documentation around this. Please can you advise whether we can send a timeout in the request to the cdn or when using the api object?

Hi @david.halewood, I’m not sure about this, so I’ll have to pass this over to the @team-tech-support. Someone there will get back to you as soon as they are able.

1 Like

Hey @david.halewood, Thanks for the report. I just created an issue on the prismic-javascript kit that you can follow here.

Don't hesitate to add your issue here in the future.

Thanks a lot.
Renaud

Thanks for that.

David

Hey @david.halewood,

to use a custom timeout, you should pass a timeoutInMs prop when instantiating the API. The documentation is a bit arid at the time of writing but you can find out more right here: https://prismicio.github.io/prismic-javascript/classes/httpclient.html

Here are all the available API options: source code.

Hope it helps :v:

1 Like

Hey @hugo.villain, thanks for your reply. I’m a bit confused though.

Let me say what I’m hoping for and then you can let me know if it’s supported.

We:

  • get the API handler from Prismic using the getApi from prismic-javascript
  • call .query to get the content using Predicates.

Can I use a timeout in this circumstance? I think not right?

I figured it out:

(await getApi(PRISMIC_API_HOST, {
  accessToken: PRISMIC_ACCESS_TOKEN,
  timeoutInMs: 1500
}));

Cheers :+1:

1 Like