/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';

var React = require('react-native');
var _ = require('underscore');

var {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} = React;

var Trevor = React.createClass({
  getInitialState: function() {
    return {
      loading: false,
      builds: []
    };
  },

  componentWillMount: function() {
    fetch('https://api.travis-ci.org/repos/ekonstantinidis/gitify/builds')
      .then((response) => response.json())
      .then((responseJson) => {
        this.setState({
          loading: false,
          builds: responseJson
        });
      })
      .catch((error) => {
        console.warn(error);
      });
  },

  renderBuilds: function () {
    var builds;
    if (this.state.builds) {
      builds = (
        <View>
          {_.map(this.state.builds, function (build) {
            console.log(build.id);
            return (
              <Text key={build.id}>{build.id}: {build.state}</Text>
            );
          })}
        </View>
      );
    }
    return builds;
  },

  render: function() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.ios.js
        </Text>
        <Text style={styles.instructions}>
          Press Cmd+R to reload,{'\n'}
          Cmd+D or shake for dev menu
        </Text>
        {this.renderBuilds()}
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('trevor', () => Trevor);

@@ -380,24 +380,45 @@
 unction() %7B%0A
+    var self = this;%0A
     fetch('h
@@ -478,16 +478,103 @@
 /builds'
+, %7B%0A      headers: %7B%0A        'Accept': 'application/vnd.travis-ci.2+json'%0A      %7D%0A    %7D
 )%0A      
@@ -571,32 +571,40 @@
  %7D)%0A      .then(
+function
 (response) =%3E re
@@ -598,18 +598,32 @@
 sponse) 
-=%3E
+%7B%0A        return
  respons
@@ -634,39 +634,37 @@
 on()
-)
 %0A      
+%7D)
 .then(
-(responseJ
+function(j
 son)
- =%3E
  %7B%0A 
@@ -670,20 +670,20 @@
         
-this
+self
 .setStat
@@ -734,20 +734,19 @@
 ds: 
-responseJson
+json.builds
 %0A   
@@ -1000,43 +1000,8 @@
 ) %7B%0A
-            console.log(build.id);%0A
     

Correct use of fetch api - set headers