# sudden fetch / CORS error

**URL:** <https://talk.observablehq.com/t/sudden-fetch-cors-error/7280>\
**Category:** Help\
**Created:** [November 14, 2022, 2:15pm UTC](https://talk.observablehq.com/t/sudden-fetch-cors-error/7280 "2022-11-14T14:15:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwebercc](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/kwebercc/32/7160_2.png) [@kwebercc](https://talk.observablehq.com/u/kwebercc)\
**Post date:** [November 14, 2022, 2:15pm UTC](https://talk.observablehq.com/t/sudden-fetch-cors-error/7280/1 "2022-11-14T14:15:39Z")

</div>

I have needed to fetch data from an API and when I originally tried to fetch the data using the API URL, I would get an error: “TypeError: Failed to fetch”. I was told to try adding a CORS proxy to the beginning of the URL, which then made it work. Everything in my notebook was working well for about a day or so but now when I open my notebook, there is another error in all the cells where I am trying to fetch data: “SyntaxError: Unexpected token ‘S’, “See /corsd”… is not valid JSON”. When I remove the CORS proxy, it just gives me the “TypeError: Failed to fetch” message.

Here is a link to one of my notebooks where I’m having this problem: [ACIS Seasonal Graphics Generator / Kaitlyn Weber / Observable](https://observablehq.com/@ktrudeau/acis-graphics-generator).

The weird thing is I am seeing these error messages in other people’s notebooks that are also using fetch… So it’s not just affecting my notebook. Here is a link to someone else’s notebook where I see the same issues:

> **[How to query a remote server: accessing PhagesDB Data](https://observablehq.com/@justine/how-to-query-a-remote-server-accessing-phagesdb-data)**
>
> PhagesDB.org is the central repository for phage-related data from the SEA-PHAGES project. It offers a web application programming interface (API) that we will be using here in order to retrieve information. You saw an API being used in the reading...

Does anyone have any recommendations?

Thank you!

P.S. When I go to inspect the page, I clicked on the Network tab and saw that the fetch errors have a status code of 403. Not sure if that info is helpful but wanted to include, just in case.

---

<div class="post-metadata">

**Author:** ![mcmcclur](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mcmcclur/32/2364_2.png) [@mcmcclur](https://talk.observablehq.com/u/mcmcclur)\
**Post date:** [November 14, 2022, 3:25pm UTC](https://talk.observablehq.com/t/sudden-fetch-cors-error/7280/2 "2022-11-14T15:25:45Z")

</div>

It’s generally a good idea to include a link to your notebook so that folks can experiment with it to diagnose the problem. If I did have the link, the first thing I’d try would be a different CORS proxy to see if you’re dealing with an intermittent problem with cors-anywhere, which is not really meant to be a production CORS proxy. My first choice would be [corsproxy.io](https://corsproxy.io/).

---

<div class="post-metadata">

**Author:** ![kwebercc](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/kwebercc/32/7160_2.png) [@kwebercc](https://talk.observablehq.com/u/kwebercc)\
**Post date:** [November 14, 2022, 6:45pm UTC](https://talk.observablehq.com/t/sudden-fetch-cors-error/7280/3 "2022-11-14T18:45:46Z")

</div>

Thank you! This is my first post ever on a discussion board like this so I appreciate the guidance 🙂

I have added the URL to one of my notebooks that was working until yesterday as well as someone else’s notebook that also has the same errors. I had used this dropdown from another notebook that allows you to select one of three CORS options. The first two options give me: “TypeError: Failed to fetch” then the last option (herokuapp) gives me: " SyntaxError: Unexpected token ‘S’, “See /corsd”… is not valid JSON" which is what I see on a lot of other notebooks too.

---

<div class="post-metadata">

**Author:** ![mcmcclur](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mcmcclur/32/2364_2.png) [@mcmcclur](https://talk.observablehq.com/u/mcmcclur)\
**Post date:** [November 14, 2022, 7:01pm UTC](https://talk.observablehq.com/t/sudden-fetch-cors-error/7280/4 "2022-11-14T19:01:01Z")

</div>

It looks to me like the following works:

```
data = fetch(
  `https://corsproxy.io/?http://data.rcc-acis.org/StnData?params={"sid":"ABIthr","sdate":"1970-02-28","edate":"2022-02-28","elems":[{"name":"avgt","interval":[1,0,0],"duration":"std","season_start":"12-01","reduce":"mean","maxmissing":9}]}`
).then((r) => r.json())

```

---

<div class="post-metadata">

**Author:** ![kwebercc](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/kwebercc/32/7160_2.png) [@kwebercc](https://talk.observablehq.com/u/kwebercc)\
**Post date:** [November 17, 2022, 12:11am UTC](https://talk.observablehq.com/t/sudden-fetch-cors-error/7280/5 "2022-11-17T00:11:21Z")

</div>

> [@mcmcclur](#):
>
> ```auto
> data = fetch(
> `https://corsproxy.io/?http://data.rcc-acis.org/StnData?params={"sid":"ABIthr","sdate":"1970-02-28","edate":"2022-02-28","elems":[{"name":"avgt","interval":[1,0,0],"duration":"std","season_start":"12-01","reduce":"mean","maxmissing":9}]}`
> ).then((r) => r.json())
> 
> ```

Yes! It does. Thank you very much!
