{"size": 1353, "ext": "js", "max_stars_repo_path": "client/src/components/ListingAnalysis/LAResults.js", "max_stars_repo_name": "blakeylakey/capybara-toolkit", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/src/components/ListingAnalysis/LAResults.js", "max_issues_repo_name": "blakeylakey/capybara-toolkit", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/src/components/ListingAnalysis/LAResults.js", "max_forks_repo_name": "blakeylakey/capybara-toolkit", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.8225806452, "max_line_length": 60, "alphanum_fraction": 0.5432372506}
import React from "react";

import LAMainContent from "./LAMainContent";
import { laResults, laRelated } from "./LAResults.defaults";
import ErrorModal from "../ErrorModal";

class LAResults extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      laResults: laResults,
      laRelated: laRelated,
      isErrored: false
    };
  }

  componentDidMount() {
    // Niche Query API
    let params = `asin=${this.props.params.asin}`;

    fetch(`/tools/la/lascrape?${params}`)
      .then(results => results.json())
      .then(results => {
        if (results.success) {
          this.setState({
            laResults: results
          });
        } else {
          this.setState({ isErrored: true });
        }
      });

    fetch(`/tools/la/laquery?${params}`)
      .then(results => results.json())
      .then(results => {
        if (results.success) {
          this.setState({
            laRelated: results
          });
        } else {
          this.setState({ isErrored: true });
        }
      });
  }

  render() {
    return (
      <>
        <ErrorModal isErrored={this.state.isErrored} />
        <LAMainContent
          laResults={this.state.laResults}
          params={this.props.params}
          laRelated={this.state.laRelated}
        />
      </>
    );
  }
}

export default LAResults;
