Advertisement
davy_yg1

pushArray

May 20th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. constructor(props) {
  2. super(props)
  3. this.state = {
  4. active: false,
  5. selected: undefined,
  6. dataSource: [],
  7. index: 0,
  8. routes: 'Lead In',
  9. isLoading: true,
  10. stage: 0
  11. };
  12. this.arrayholder = [];
  13. this.arrayholder2 = [];
  14.  
  15. }
  16.  
  17.  
  18. doRequest = () => {
  19.  
  20. // deal api
  21. fetch(deal_api)
  22. .then(response => response.json())
  23. .then(responseJson => {
  24. this.setState(
  25. {
  26. isLoading: false,
  27. dataSource: responseJson,
  28. },
  29. function() {
  30. let array = [];
  31. this.arrayholder = responseJson;
  32. if (arrayholder.length > 0){
  33. array.push(arrayholder)
  34. }
  35. }
  36. );
  37. })
  38. .catch(error => {
  39. console.error(error);
  40. });
  41.  
  42. // organization api
  43. fetch(organization_api)
  44. .then(response => response.json())
  45. .then(responseJson => {
  46.  
  47. this.arrayholder2 = responseJson;
  48. if (arrayholder2.length > 0){
  49. array.push(arrayholder2)
  50. }
  51.  
  52. this.setState(
  53. {
  54. isLoading: false,
  55. dataSource: array,
  56. }
  57. );
  58. })
  59. .catch(error => {
  60. console.error(error);
  61. });
  62.  
  63. console.log(dataSource)
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement