Advertisement
Guest User

Untitled

a guest
Nov 30th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import logo from './logo.svg';
  3. import './App.css';
  4. import qs from 'qs';
  5.  
  6.  
  7.  
  8.  
  9. class App extends Component {
  10. constructor(props) {
  11. super(props);
  12.  
  13. this.state = {
  14. data: null,
  15. };
  16.  
  17. }
  18.  
  19.  
  20.  
  21. componentDidMount() {
  22.  
  23. fetch('http://localhost:2018/WebApi/token', {
  24. method: 'POST',
  25. headers: {
  26. 'Authorization': 'Bearer Q4rCzFf8Aji11EdnEQEGWEPcfDH34ie7FCQl9eVxx-85uKa2IplxTBJCpomCMhAk-cw4JI5tkoCykL5mckvz_oSGtO5xz255bL_3cKdZmr7wH8e4jVH0mb_OVCta9IYtglfnCb9Npi4b_A8GbNXEL2f9kcikxCyqqQwGaaVOMxiE4vDCOEPTGsmZivdHDKGtu3KW1aRyg2CfpimAMxOsS4IWAEk_FqJHQTvTHuI3Zoc4_WoDnrkVXz-IGUxhRI7da8bv7JwzN537oru_MAj0hYhCoRf1oirtBYE01wWw9WnOVy3EiMgH0s7chFR534-V',
  27. 'Content-Type': 'application/x-www-form-urlencoded'
  28. },
  29. body: qs.stringify({
  30. username: 'FEUP',
  31. password: 'qualquer1',
  32. company: 'FRUITSHOP',
  33. instance: 'Default',
  34. grant_type: 'password',
  35. Line: 'professional'
  36. })
  37. }).then(response => response.json())
  38. .then(data => this.setState({ data }));
  39. console.log(this.state);
  40.  
  41.  
  42.  
  43. }
  44.  
  45. render() {
  46. const { hits } = this.state;
  47. console.log(this.state);
  48. console.log(hits);
  49.  
  50. return (
  51. <div className="App">
  52. <header className="App-header">
  53. <img src={logo} className="App-logo" alt="logo" />
  54. <p>
  55. Edit <code>src/App.js</code> and save to reload.
  56. </p>
  57. <a
  58. className="App-link"
  59. href="https://reactjs.org"
  60. target="_blank"
  61. rel="noopener noreferrer"
  62. >
  63. Learn React
  64. </a>
  65. </header>
  66. </div>
  67. );
  68. }
  69. }
  70.  
  71. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement