# How to handle getJSON errors?

**URL:** <https://discourse.gohugo.io/t/how-to-handle-getjson-errors/8351>\
**Category:** support\
**Created:** [September 12, 2017, 11:17pm UTC](https://discourse.gohugo.io/t/how-to-handle-getjson-errors/8351 "2017-09-12T23:17:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhruv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dhruv/32/5247_2.png) [@dhruv](https://discourse.gohugo.io/u/dhruv)\
**Post date:** [September 12, 2017, 11:17pm UTC](https://discourse.gohugo.io/t/how-to-handle-getjson-errors/8351/1 "2017-09-12T23:17:16Z")

</div>

I’m getting a bunch of JSON feeds using the getJSON function. However, not all those feeds exist.

Is there anyway to catch this error and ignore it?

```auto
Template changed /Users/..../partials/mytemplate.html
ERROR 2017/09/12 15:44:28 Failed to get json resource https:...

```

---

<div class="post-metadata">

**Author:** ![smiileTeam](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@smiileTeam](https://discourse.gohugo.io/u/smiileTeam)\
**Post date:** [May 23, 2018, 4:20pm UTC](https://discourse.gohugo.io/t/how-to-handle-getjson-errors/8351/2 "2018-05-23T16:20:38Z")

</div>

Hi,

any answer to this ?

getJSON is supposed to return nil when an error occures, we’ve tried to test our var against nil in the following way but still hugo crash on with an error on getJSON

ERROR 2018/05/23 18:12:13 Error while rendering “page” in “ville/”: template:…/single.html:144:11: executing “main” at \<partial "block-local…\>: error calling partial: template: theme/partials/block-local-.html:64:21: executing “theme/partials/block-local.html” at \<getJSON ($.Scratch.G…\>: error calling getJSON: Get [http://127.0.0.1//test.md:](http://127.0.0.1//test.md:) EOF

In our template  
{{ dataJSON := (getJSON (.Scratch.Get “baseurlapi”) $element) }}  
{{ if ne $dataJSON nil }}  
  
{{ end }}  
{{ end }}

---

<div class="post-metadata">

**Author:** ![smiileTeam](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@smiileTeam](https://discourse.gohugo.io/u/smiileTeam)\
**Post date:** [May 23, 2018, 4:34pm UTC](https://discourse.gohugo.io/t/how-to-handle-getjson-errors/8351/3 "2018-05-23T16:34:05Z")

</div>

looks like errors are catched in hugolib/site.go, we would need that error to be silent and not killing hugo, any advice to achieve that ?

---

<div class="post-metadata">

**Author:** ![magnusthorek](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/magnusthorek/32/11937_2.png) [@magnusthorek](https://discourse.gohugo.io/u/magnusthorek)\
**Post date:** [August 15, 2018, 12:14pm UTC](https://discourse.gohugo.io/t/how-to-handle-getjson-errors/8351/4 "2018-08-15T12:14:33Z")

</div>

That would be indeed very interesting

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [August 15, 2018, 12:21pm UTC](https://discourse.gohugo.io/t/how-to-handle-getjson-errors/8351/5 "2018-08-15T12:21:00Z")

</div>

I’ve opened an issue to see what bep has to say. Let’s continue further discussion there:

> <https://github.com/gohugoio/hugo/issues/5076>

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [October 22, 2020, 1:25pm UTC](https://discourse.gohugo.io/t/how-to-handle-getjson-errors/8351/6 "2020-10-22T13:25:52Z")

</div>

Since [`fdfa4a5`](https://github.com/gohugoio/hugo/commit/fdfa4a5fe62232f65f1dd8d6fe0c500374228788) the following can be entered in a project’s config to allow building a project even if a remote source called by `getJSON` is missing.

```auto
If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site config:
ignoreErrors = ["error-remote-getjson"]

```

P.S. This option will be available in the next Hugo release.

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [October 22, 2020, 2:54pm UTC](https://discourse.gohugo.io/t/how-to-handle-getjson-errors/8351/7 "2020-10-22T14:54:35Z")

</div>

> 2 years later

Wow! I am still using Hugo, but I believe I haven’t updated it in about that much time. Now’s a good reason, at least for me, to update it on the next release 🤞 😃

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [October 24, 2020, 2:54pm UTC](https://discourse.gohugo.io/t/how-to-handle-getjson-errors/8351/8 "2020-10-24T14:54:42Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
