import React, { Component } from 'react';
import '../App.css';
let request = require('superagent');

class SearchBar extends Component {

  constructor() {
    super();

    this.previous_input = "";
  }

  request() {
    request
      .get("http://localhost:5000/search/" + this.previous_input)
      .accept('json')
      .end( (err, res) => {
        console.log('err: ' + err);
        if (res) {
          console.log(JSON.parse(res.text));
        }
      });
  }

  render() {
    return (
      <div className="search-bar">
        <input id="search-input" className="search-input" type="text" placeholder="nick 0, nick 1, ..." onKeyUp={this.search.bind(this)}></input>
      </div>
    );
  }

  search() {
    var raw_input = document.getElementById('search-input').value;
    this.previous_input = raw_input;
    this.request();
    //console.log("i did stuff");
    // send raw_input to Flask here!
  }

}

export default SearchBar;

@@ -162,17 +162,16 @@
 uper();%0A
-%0A
     this
@@ -341,61 +341,120 @@
  =%3E 
-%7B%0A        console.log('err: ' + err);
+this.handle_response(err, res));%0A  %7D%0A%0A  handle_response(error, response) %7B%0A    if(error)%7B%0A
 %0A    
+%7D%0A
     if
- 
 (res
+ponse
 ) %7B%0A
@@ -463,24 +463,210 @@
     
-    console.log(
+if(response.status === 400)%7B%0A        this.props.onSearch(%5B%5D);%0A      %7D%0A      else if(response.text === '') %7B%0A        this.props.onSearch(null)%0A      %7Delse%7B%0A        try %7B%0A            var responseObject = 
 JSON
@@ -679,36 +679,194 @@
 (res
+ponse
 .text)
-);%0A        %7D%0A      %7D);
+;%0A            this.props.onSearch(responseObject%5B'nick_list'%5D);%0A        %7D catch (Error) %7B%0A            // Isn't JSON so we do nothing with the response.%0A        %7D%0A      %7D%0A    %7D
 %0A  %7D
@@ -1038,13 +1038,14 @@
 %22 on
-KeyUp
+Change
 =%7Bth
@@ -1241,79 +1241,8 @@
 ();%0A
-    //console.log(%22i did stuff%22);%0A    // send raw_input to Flask here!%0A
   %7D%0A

Add more proper response handling sending the list to AppBody