Basically we’re using forestry.io with a client. For a specific content types we allow them to input a Vimeo URL. When the site is built we use getJSON to pull from the Vimeo API to get video thumbnails, embed codes, ect ect.
However sometimes content editors will paste an incorrect URL Other times they might change privacy settings for the video such making a video private or giving it a private link. (This is the issue we’ve run into most often)
Whenever either of these happens getJSON no longer can fetch the url preventing builds from finishing (both production builds and the Forestry preview server).
What I’m Trying To Accomplish
I’d like it if I could create a fallback for when getJSON fails. Then just display a simple error message in place of the video thumbnail and video player.
It seems to me that getJSON doesn’t have any way to handle errors it just causes the build to fail. It would be nice if we had something similar to the catch() method used with Javascript Promises.
Is something like this possible with Hugo? I’ve searched the documentation, but couldn’t seem to find anything.
Ideating: I use getJSON and sometimes don’t have anything to pull in. I adjusted my templates to use with, and I have else statements to show it not loading.