catch error from google trends API, let it result in empty array
Этот коммит содержится в:
		
							родитель
							
								
									f3713af07e
								
							
						
					
					
						Коммит
						60ed620c13
					
				| @ -115,7 +115,8 @@ | ||||
|         data: await loadGoogleTrendsData('disinformation'), | ||||
|         selected: false | ||||
|       } | ||||
|     ]; | ||||
|     ] | ||||
|     .filter((d) => d.data.length > 0); | ||||
| 
 | ||||
|     preloadImages(data); | ||||
| 
 | ||||
|  | ||||
| @ -1,13 +1,17 @@ | ||||
| import { googleTrendsApiPath } from '../inputs/dataPaths'; | ||||
| 
 | ||||
| const loadGoogleTrendsData = async (keyword) => { | ||||
|   let data = []; | ||||
|   try { | ||||
|     const response = await fetch(`${googleTrendsApiPath}${encodeURIComponent(keyword)}`); | ||||
|   const data = (await response.json()).map((d) => ({ | ||||
|     data = (await response.json()).map((d) => ({ | ||||
|       ...d, | ||||
|       date: new Date(d.time * 1000) | ||||
|   })); | ||||
| console.log(data) | ||||
|   return(data.filter((d) => !d.isPartial)); | ||||
|     })) | ||||
|     .filter((d) => !d.isPartial); | ||||
|   } finally { | ||||
|     return(data); | ||||
|   } | ||||
| }; | ||||
| 
 | ||||
| export default loadGoogleTrendsData; | ||||
|  | ||||
		Загрузка…
	
	
			
			x
			
			
		
	
		Ссылка в новой задаче
	
	Block a user
	 higsch
						higsch