Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     componentDidMount() {
  2.         const url = API_URL + "/api/customers";
  3.         fetch(url, {
  4.             headers: {
  5.                 'Authorization': 'Bearer ' + GetTokenCookie("uid")
  6.             }
  7.         })
  8.             .then(res => res.json())
  9.             .then(res => {
  10.                 this.setState({ profile: res });
  11.                 this.setState({ isLoading: false });
  12.                 this.setChartData();
  13.             })
  14.             .catch(error => this.setState({ error, isLoading: false }));
  15.     }
  16.  
  17.     setChartData() {
  18.         this.setState({
  19.             chartData: {
  20.                 labels: ['Boston', 'Worcester', 'Springfield', 'Lowell', 'Cambridge', 'New Bedford'],
  21.                 datasets: [
  22.                     {
  23.                         label: 'Population',
  24.                         data: [
  25.                             617594,
  26.                             181045,
  27.                             153060,
  28.                             106519,
  29.                             105162,
  30.                             95072
  31.                         ],
  32.                         backgroundColor: [
  33.                             'rgba(255, 99, 132, 0.6)',
  34.                             'rgba(54, 162, 235, 0.6)',
  35.                             'rgba(255, 206, 86, 0.6)',
  36.                             'rgba(75, 192, 192, 0.6)',
  37.                             'rgba(153, 102, 255, 0.6)',
  38.                             'rgba(255, 159, 64, 0.6)',
  39.                             'rgba(255, 99, 132, 0.6)'
  40.                         ]
  41.                     }
  42.                 ]
  43.             }
  44.         });
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement