Solved

TypeError: Failed to fetch

  • 15 September 2022
  • 10 replies
  • 2297 views

Badge

I’m getting a lot of log errors with the messages:

 

console error: Amplitude Logger [Error]: TypeError: Failed to fetch

 

and…

console error: Amplitude Logger [Error]: TypeError: Load failed

 

We are using de JS Library on a Nuxt App. Any ideias about how to fix it?

 

icon

Best answer by eddie.gaona 30 September 2022, 01:06

View original

10 replies

Userlevel 5
Badge +9

Hello @fernando nice to meet you!

 

Can you link to the version of the JS SDK you are using, please?

Are you referring to this JS SDK, here?

Badge

@eddie.gaona I’m using the typescript version https://www.docs.developers.amplitude.com/data/sdks/typescript-browser/

 

We have an saas and use Datadog to monitoring our logs. For some reason, we are we are receiving a lot of this Amplitude errors.

 

Userlevel 5
Badge +9

@fernando Thank you for the information!

Are you unable to log events to your project or do some events get ingested and others don’t? Can you share how you are initializing the SDK but remove any sensitive data such as the API Key.

Badge

Hi @eddie.gaona , we receive around 1MM events a month.

 

I don’t think I can share my code because there is a lot of business logic. Maybe you can check a live example? 

You can fill this form and see the events been post https://form.respondi.app/NNMni5MV

Userlevel 5
Badge +9

Hello @fernando no worries makes sense! I will check out internally and return with updates once they are available. Thank you!

Userlevel 5
Badge +9

Hello @fernando hope you are doing well!

We have tried to replicate the issue you are reporting with no luck so far.

image

 

To get more details, could you share the npm package and version of our SDK you are using, and how the SDK is being used? Also note that Nuxt supports SSR (Nuxt - Server Side Rendering). Our SDK might have limitations in the SSR case.

Badge

Hi @eddie.gaona , for all my tests everything works as well. However, we still receiving hundreds of erros a day. Maybe there is some kind of quote limit?

 

About our SDK, it’s "@amplitude/analytics-browser": "^1.3.0"

 

 

The app is running in SSR, but the library is loaded in client side only. What is the best way to implement Amplitude with Nuxt SSR?

 

Badge

Hey @eddie.gaona , any news about this issue?

Userlevel 5
Badge +9

Hello @fernando , as there are no other details to go off of there is not much we can advise at this time. Would it be possible for you to provide the call stack or a way to reproduce it.

 

As for best practices in Nuxt implementation, we have an example for the Next (Amplitude-TypeScript/examples/browser/next-app at main · amplitude/Amplitude-TypeScript · GitHub) (similar to Nuxt). I am not an expert on SSR, but if you have any specific question related to amplitude SDK in their SSR app, I am happy to help.

I use on my site Marketing Analytics Browser
Сonnected and use CDN package 

// include package a CDN

amplitude.init("myID", null, {
pageViewTracking: true,
}).promise.then((result) => {
initFbTag();
initGoogleTag();
});

 

Sometimes in the console such an error (2 times in a row)

 

Network cURL 

Network error
curl 'https://api2.amplitude.com/2/httpapi' \
-H 'authority: api2.amplitude.com' \
-H 'accept: */*' \
-H 'accept-language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'origin: https://brighterly.loc' \
-H 'pragma: no-cache' \
-H 'referer: https://brighterly.loc/' \
-H 'sec-ch-ua: "Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
-H 'sec-fetch-dest: empty' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-site: cross-site' \
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36' \
--data-raw '{"api_key":"myID","events":[{"device_id":"1918a78d-e5eb-4c03-af63-d02ea2a1c510","session_id":1666619870992,"time":1666620866874,"platform":"Web","os_name":"Chrome","os_version":"106.0.0.0","device_model":"Mac OS","language":"ru-RU","ip":"$remote","insert_id":"b498a62b-fdf0-4dc8-b5b7-68ab2413dab8","event_type":"Page view Booking","event_properties":{"Page name":"Booking","Page link":"https://brighterly.loc/booking/"},"event_id":0,"library":"amplitude-ma-ts/0.2.0"},{"device_id":"1918a78d-e5eb-4c03-af63-d02ea2a1c510","session_id":1666619870992,"time":1666620866876,"platform":"Web","os_name":"Chrome","os_version":"106.0.0.0","device_model":"Mac OS","language":"ru-RU","ip":"$remote","insert_id":"1949b8b7-01b6-4d5f-bec0-4f96393c676f","event_type":"Page View","event_properties":{"referrer":"https://brighterly.loc/pricing/","referring_domain":"brighterly.loc","page_domain":"brighterly.loc","page_location":"https://brighterly.loc/booking/","page_path":"/booking/","page_title":"Booking | Brighterly: Start a FREE trial","page_url":"https://brighterly.loc/booking/"},"event_id":1,"library":"amplitude-ma-ts/0.2.0"},{"device_id":"1918a78d-e5eb-4c03-af63-d02ea2a1c510","session_id":1666619870992,"time":1666620867269,"platform":"Web","os_name":"Chrome","os_version":"106.0.0.0","device_model":"Mac OS","language":"ru-RU","ip":"$remote","insert_id":"3953bf2f-6e30-4d8a-b13d-78e2fde222c0","event_type":"Page view Booking","event_properties":{"Page name":"Booking","Page link":"https://brighterly.loc/booking/"},"event_id":0,"library":"amplitude-ma-ts/0.2.0"},{"device_id":"1918a78d-e5eb-4c03-af63-d02ea2a1c510","session_id":1666619870992,"time":1666620867270,"platform":"Web","os_name":"Chrome","os_version":"106.0.0.0","device_model":"Mac OS","language":"ru-RU","ip":"$remote","insert_id":"7944e692-a304-41c5-9d74-ee162d7ddd48","event_type":"Page View","event_properties":{"referrer":"https://brighterly.loc/pricing/","referring_domain":"brighterly.loc","page_domain":"brighterly.loc","page_location":"https://brighterly.loc/booking/","page_path":"/booking/","page_title":"Booking | Brighterly: Start a FREE trial","page_url":"https://brighterly.loc/booking/"},"event_id":1,"library":"amplitude-ma-ts/0.2.0"},{"device_id":"1918a78d-e5eb-4c03-af63-d02ea2a1c510","session_id":1666619870992,"time":1666620868753,"platform":"Web","os_name":"Chrome","os_version":"106.0.0.0","device_model":"Mac OS","language":"ru-RU","ip":"$remote","insert_id":"444da70e-6673-4e93-8418-ee49becd0b07","event_type":"Page view Booking","event_properties":{"Page name":"Booking","Page link":"https://brighterly.loc/booking/"},"event_id":0,"library":"amplitude-ma-ts/0.2.0"},{"device_id":"1918a78d-e5eb-4c03-af63-d02ea2a1c510","session_id":1666619870992,"time":1666620868753,"platform":"Web","os_name":"Chrome","os_version":"106.0.0.0","device_model":"Mac OS","language":"ru-RU","ip":"$remote","insert_id":"f2c65024-3115-431b-96b2-76210b073be7","event_type":"Page View","event_properties":{"referrer":"https://brighterly.loc/pricing/","referring_domain":"brighterly.loc","page_domain":"brighterly.loc","page_location":"https://brighterly.loc/booking/","page_path":"/booking/","page_title":"Booking | Brighterly: Start a FREE trial","page_url":"https://brighterly.loc/booking/"},"event_id":1,"library":"amplitude-ma-ts/0.2.0"},{"device_id":"1918a78d-e5eb-4c03-af63-d02ea2a1c510","session_id":1666619870992,"time":1666620869925,"platform":"Web","os_name":"Chrome","os_version":"106.0.0.0","device_model":"Mac OS","language":"ru-RU","ip":"$remote","insert_id":"8f03ffee-41a8-4a34-88c2-950fe0d2cd30","event_type":"Page view Booking","event_properties":{"Page name":"Booking","Page link":"https://brighterly.loc/booking/"},"event_id":0,"library":"amplitude-ma-ts/0.2.0"},{"device_id":"1918a78d-e5eb-4c03-af63-d02ea2a1c510","session_id":1666619870992,"time":1666620869926,"platform":"Web","os_name":"Chrome","os_version":"106.0.0.0","device_model":"Mac OS","language":"ru-RU","ip":"$remote","insert_id":"3b47465a-dbcc-4354-93af-40680af98de5","event_type":"Page View","event_properties":{"referrer":"https://brighterly.loc/pricing/","referring_domain":"brighterly.loc","page_domain":"brighterly.loc","page_location":"https://brighterly.loc/booking/","page_path":"/booking/","page_title":"Booking | Brighterly: Start a FREE trial","page_url":"https://brighterly.loc/booking/"},"event_id":1,"library":"amplitude-ma-ts/0.2.0"}],"options":{}}' \
--compressed

 

 

 

Reply