mirror of
https://github.com/status-im/react-native.git
synced 2025-03-03 10:50:35 +00:00
Merge pull request #367 from tadeuzagallo/rotten-tomatoes
Update tutorial - use sample data
This commit is contained in:
commit
a8e32207e8
@ -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"
|
||||
|
1
docs/MoviesExample.json
Normal file
1
docs/MoviesExample.json
Normal file
File diff suppressed because one or more lines are too long
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user