mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Merge pull request #367 from tadeuzagallo/rotten-tomatoes
Update tutorial - use sample data
This commit is contained in:
commit
a8e32207e8
3 files changed
+7
-6
No files matched your search
@@ -32,7 +32,7 @@ var MovieScreen = require('./MovieScreen');
|
||||
var fetch = require('fetch');
|
||||
|
||||
var API_URL = 'http://api.rottentomatoes.com/api/public/v1.0/';
|
||||
var API_KEYS = [/* '7waqfqbprs7pajbz28mqf6vz' - Limit Exceeded,*/ 'y4vwv8m33hed9ety83jmv52f'];
|
||||
var API_KEYS = ['7waqfqbprs7pajbz28mqf6vz', 'y4vwv8m33hed9ety83jmv52f'];
|
||||
|
||||
// Results should be cached keyed by the query
|
||||
// with values of null meaning "being fetched"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"total":24,"movies":[{"id":"11494","title":"Chain Reaction","year":1996,"mpaa_rating":"PG-13","runtime":106,"release_dates":{"theater":"1996-08-02","dvd":"2001-05-22"},"ratings":{"critics_rating":"Rotten","critics_score":16,"audience_rating":"Spilled","audience_score":27},"synopsis":"","posters":{"thumbnail":"http://resizing.flixster.com/DeLpPTAwX3O2LszOpeaMHjbzuAw=/53x77/dkpu1ddg7pbsk.cloudfront.net/movie/11/16/47/11164719_ori.jpg","profile":"http://resizing.flixster.com/DeLpPTAwX3O2LszOpeaMHjbzuAw=/53x77/dkpu1ddg7pbsk.cloudfront.net/movie/11/16/47/11164719_ori.jpg","detailed":"http://resizing.flixster.com/DeLpPTAwX3O2LszOpeaMHjbzuAw=/53x77/dkpu1ddg7pbsk.cloudfront.net/movie/11/16/47/11164719_ori.jpg","original":"http://resizing.flixster.com/DeLpPTAwX3O2LszOpeaMHjbzuAw=/53x77/dkpu1ddg7pbsk.cloudfront.net/movie/11/16/47/11164719_ori.jpg"},"abridged_cast":[{"name":"Keanu Reeves","id":"162654049","characters":["Eddie Kasalivich"]},{"name":"Morgan Freeman","id":"162652224","characters":["Paul Shannon"]},{"name":"Rachel Weisz","id":"162653682","characters":["Dr. Lily Sinclair"]},{"name":"Fred Ward","id":"162667867","characters":["Agt. Leon Ford"]},{"name":"Kevin Dunn","id":"162664658","characters":["Agt. Doyle"]}],"alternate_ids":{"imdb":"0115857"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/11494.json","alternate":"http://www.rottentomatoes.com/m/1072457-chain_reaction/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/11494/cast.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/11494/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/11494/similar.json"}},{"id":"770920361","title":"React! A Woman's Guide to Safety and Basic Self-Defense","year":1996,"mpaa_rating":"Unrated","runtime":"","release_dates":{"dvd":"1996-07-29"},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"","posters":{"thumbnail":"http://resizing.flixster.com/m7G-weBZPYfnoqSiF59LIPPYOuM=/44x81/dkpu1ddg7pbsk.cloudfront.net/movie/10/97/47/10974721_ori.jpg","profile":"http://resizing.flixster.com/m7G-weBZPYfnoqSiF59LIPPYOuM=/44x81/dkpu1ddg7pbsk.cloudfront.net/movie/10/97/47/10974721_ori.jpg","detailed":"http://resizing.flixster.com/m7G-weBZPYfnoqSiF59LIPPYOuM=/44x81/dkpu1ddg7pbsk.cloudfront.net/movie/10/97/47/10974721_ori.jpg","original":"http://resizing.flixster.com/m7G-weBZPYfnoqSiF59LIPPYOuM=/44x81/dkpu1ddg7pbsk.cloudfront.net/movie/10/97/47/10974721_ori.jpg"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/770920361.json","alternate":"http://www.rottentomatoes.com/m/react_a_womans_guide_to_safety_and_basic_selfdefense/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/770920361/cast.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/770920361/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/770920361/similar.json"}},{"id":"770819043","title":"Reaction","year":"","mpaa_rating":"Unrated","runtime":13,"release_dates":{},"ratings":{"critics_score":-1,"audience_score":100},"synopsis":"","posters":{"thumbnail":"http://d3biamo577v4eu.cloudfront.net/static/images/redesign/poster_default_thumb.gif","profile":"http://d3biamo577v4eu.cloudfront.net/static/images/redesign/poster_default_thumb.gif","detailed":"http://d3biamo577v4eu.cloudfront.net/static/images/redesign/poster_default_thumb.gif","original":"http://d3biamo577v4eu.cloudfront.net/static/images/redesign/poster_default_thumb.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/770819043.json","alternate":"http://www.rottentomatoes.com/m/reaction/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/770819043/cast.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/770819043/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/770819043/similar.json"}},{"id":"771364188","title":"Reactor","year":2013,"mpaa_rating":"Unrated","runtime":34,"release_dates":{},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"","posters":{"thumbnail":"http://d3biamo577v4eu.cloudfront.net/static/images/redesign/poster_default_thumb.gif","profile":"http://d3biamo577v4eu.cloudfront.net/static/images/redesign/poster_default_thumb.gif","detailed":"http://d3biamo577v4eu.cloudfront.net/static/images/redesign/poster_default_thumb.gif","original":"http://d3biamo577v4eu.cloudfront.net/static/images/redesign/poster_default_thumb.gif"},"abridged_cast":[],"alternate_ids":{"imdb":"2828874"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771364188.json","alternate":"http://www.rottentomatoes.com/m/reactor_2013/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771364188/cast.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771364188/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771364188/similar.json"}},{"id":"391535485","title":"Chain Reaction (HLine truncated
|
||||
+5
-5
@@ -197,11 +197,11 @@ Fetching data from Rotten Tomatoes's API isn't really relevant to learning React
|
||||
Add the following constants to the top of the file (typically below the requires) to create the REQUEST_URL used to request data with.
|
||||
|
||||
```javascript
|
||||
var API_KEY = '7waqfqbprs7pajbz28mqf6vz';
|
||||
var API_URL = 'http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json';
|
||||
var PAGE_SIZE = 25;
|
||||
var PARAMS = '?apikey=' + API_KEY + '&page_limit=' + PAGE_SIZE;
|
||||
var REQUEST_URL = API_URL + PARAMS;
|
||||
/**
|
||||
* For quota reasons we replaced the Rotten Tomatoes' API with a sample data of
|
||||
* their very own API that lives in React Native's Gihub repo.
|
||||
*/
|
||||
var REQUEST_URL = 'https://raw.githubusercontent.com/facebook/react-native/master/docs/MoviesExample.json';
|
||||
```
|
||||
|
||||
Add some initial state to our application so that we can check `this.state.movies === null` to determine whether the movies data has been loaded or not. We can set this data when the response comes back with `this.setState({movies: moviesData})`. Add this code just above the render function inside our React class.
|
||||
|
||||
Reference in new issue
Block a user