Saturday, 20 May 2017

Hiding fetch request keys

I am using the new OMDB api, and want to keep the fetch requests (that include the key) out of visibility on client-side.

Here is an example of the problem whenever a user opens up dev tools:feelsbad.

I do all my calls in React like so:

  import OmdbKey from './OmdbKey';
  populate(keystrokes) {
    let query = "http://www.omdbapi.com/?s=";
    fetch(query + keystrokes + '&apikey=' + OmdbKey )
      .then((response) => {
        response.json().then((json) => {
          this.setState({ results: json.Search });
        });
      });
  }

Is there some way to do this so I can hide the key in the GET request? How else should I approach this if not?

Thanks



via user3335607

No comments:

Post a Comment