0

import React, { useEffect } from "react";
import axios from "axios";
const YoutubeApi = ({ term }) => {
  const apiKey = "AIzaSy...";

  const fetchUrl = `https://www.googleapis.com/youtube/v3/search?key=${apiKey}&channelId=@freecodecamp`;

  useEffect(() => {
    axios.get(fetchUrl).then((response) => {
      console.log(response);
    });
  }, []);
  return <div>{term}</div>;
};

export default YoutubeApi;

above is the code and want the result from youtube data api but it returns an error .

caught (in promise) AxiosError {message: 'Request failed with status code 403', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: XMLHttpRequest, …} Promise.then (async) (anonymous

how i can get my response from the youtube data api

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33

0 Answers0