Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3722

Addressing Errors in YouTube's Search Suggestion API Implementation

$
0
0

i am building youtube clone and i want to show the suggestions when a user can search something.

https://clients1.google.com/complete/search?client=youtube&gs_ri=youtube&ds=yt&q=

i get a api from here but when i call this api i'm getting an error "Access to fetch at 'https://suggestqueries.google.com/complete/search?client=youtube&ds=yt&q=iphone' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.". How to resolve this issue.

const YOUTUBE_SEARCH_SUGGESTION_API = "https://clients1.google.com/complete/search?client=youtube&gs_ri=youtube&ds=yt&q=";const searchSuggestionQuery = async () => {    try {        const response = await fetch(YOUTUBE_SEARCH_SUGGESTION_API + searchQuery);        const data = await response.json();      console.log(data);    } catch (error) {        console.error("Error in fetching search suggestion query:", error);    }}useEffect( () => {searchSuggestionQuery();}, [ searchQuery] )

Viewing all articles
Browse latest Browse all 3722

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>