Laravel:在compile.php第7772行中的RuntimeException:在进行有角度的http请求时

时间:2016-10-22 20:26:34

标签: javascript angularjs laravel http laravel-5

我有时候在Laravel api上使用angular $ http方法时会出现此错误。请帮助我理解这个错误是什么以及我能做些什么来解决它。我已将错误日志放在codepen中以便更好地查看。

这是代码笔的链接:http://codepen.io/anon/pen/GjzJOX

class AutoCompleteSearch extends Component {
  constructor(props) {
    super(props);
    this.state = {
      value: '',
      suggestions: []
    }
  }

  autoSearchInputChange(e) {
    let searchValue = e.target.value;
    if (!searchValue.trim()) {
      this.setState({ value : '', suggestions: [] })
      return ;
    }

    if (searchValue.length >= 3) {
      setTimeout(() => {
      searchDoctorByName(searchValue).then((response) => {
        this.setState({ value : searchValue, suggestions: response.data })
      })}, 1000);
    }
  }

  selectItemFromList(doctorObject) {
    this.setState({
      value: doctorObject.name ,
      suggestions: [doctorObject]
    });
  console.log(this.state);
}

render() {
  let renderItems = () => {
    let listItems = this.state.suggestions.map((suggestion, index) => {
      let doctorObject = suggestion;
        return (
          <li onClick={() => this.selectItemFromList(doctorObject)} key={index}>
          {doctorObject.name}
          </li>
          );
      });
    return (
      <div>
      <ul className="doctor-list">
      {listItems}
      </ul>
      </div>
    );

  }

    return (
        <div className="form-group">
        <label className="control-label form-label col-md-4" htmlFor="auto-complete-search">Doctor Name</label>
        <div className="col-md-20">
          <input className="custom-input"type="text" ref="test" id="auto-complete-search" required
          placeholder="Enter Doctor name"
          onChange={(e) => this.autoSearchInputChange(e)}
          />
            {this.state.suggestions.length > 0 ? renderItems() : null}

        </div>
      </div>
    );
  }
}

export default AutoCompleteSearch;

1 个答案:

答案 0 :(得分:0)

在项目根目录下运行以下命令:
php artisan key:generate