Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`Google Maps API warning: NoApiKeys ` when trying to access Youtube Data Api v3

I'm following the Modern Redux With React tutorial, and trying to access the Youtube Data API v3, but in Chrome console I get the error Google Maps API warning: NoApiKeys. I'm not sure why I'm getting a Google Maps warning, because I registered an API key for Youtube.

Clicked Go to Credentials.

Clicked Go to Credentials.

Clicked "API Key".

Clicked "API Key".

Clicked "Browser".

Clicked "Browser".

Set name and clicked create.

Set name and clicked create.

Copied and pasted API into JS file.

Copied and pasted API into JS file.

import React, {Component} from 'react';
import * as ReactDOM from "react/lib/ReactDOM";
import YTSearch from 'youtube-api-search';

import SearchBar from './components/search_bar';


const API_KEY = 'AIzaSyD9WN2t4lhIZ5Es34jwaerM98r2nSutLJs';


class App extends Component {

  constructor(props) {
    super(props);

      this.state = {videos: []};

    YTSearch({key: API_KEY, term: 'surfboards'}, (videos) => {
      console.log(data);
      this.setState({videos});
    });
  }

  render() {
    return (
      <div>
        <SearchBar />
      </div>
    );
  }
}

ReactDOM.render(<App />, document.querySelector('.container'));
like image 948
domi91c Avatar asked Mar 18 '16 00:03

domi91c


People also ask

Why is Youtube API key not valid?

Your API key may not be working because you're using it for the wrong project. Be sure you're using the key for the project that you created it for, especially if you created multiple projects at the same time. If it's still not working, consider creating a new API key entirely.

Is Google Maps API no longer free?

Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit).


2 Answers

This is because you have "maps.googleapis.com/maps/api/js" in your index.html file. Comment out that line to prevent google maps trying to load up without a key

like image 117
Nigel Avatar answered Sep 19 '22 13:09

Nigel


You must be loading the Google Maps API without specifying an API key.

Have a look in the Network tab of Chrome Dev Tools and see if anything's loading /maps/api/js - then try and track down which part of your code is pulling in the Google Maps API.

like image 34
mhansen Avatar answered Sep 20 '22 13:09

mhansen