Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. class NSInventory extends React.Component{
  2. constructor(props){
  3. super(props);
  4. this.state = {
  5. prodList:[],
  6. storeList:[]
  7. };
  8. this.componentDidMount = this.componentDidMount.bind(this);
  9. this.getProducts = this.getProducts.bind(this);
  10. this.getStoreByCode = this.getStoreByCode.bind(this);
  11. }
  12.  
  13. getProducts() {
  14. return(
  15. axios.post(API_URL, {
  16. query: `query{
  17. allProducts{
  18. name
  19. type
  20. quantity
  21. cost
  22. }
  23. }`
  24. }).then(res => {
  25. this.setState({
  26. prodList:res.data.data.allProducts
  27. })
  28. })
  29. )
  30. };
  31.  
  32. getStoreByCode() {
  33. return(
  34. axios.post(API_URL, {
  35. query: `query{
  36. storeByCode(code: ${2})
  37. {
  38. code
  39. name
  40. type
  41. owner
  42. ubication
  43. dates
  44. description
  45. img
  46. }
  47. }`
  48. }).then(res => {
  49. var dict = res.data.data.storeByCode
  50. var array = []
  51. for(var key in dict) {
  52. var value = dict[key];
  53. array.push(value)
  54. }
  55. console.log(array)
  56. this.setState({
  57. storeInfo: array
  58. })
  59. })
  60. )
  61. };
  62.  
  63.  
  64.  
  65. componentDidMount(){
  66. getProducts();
  67. getStoreByCode();
  68. };
  69.  
  70.  
  71. displayStoreDetails(){
  72. //display of store details
  73.  
  74. )
  75. }
  76.  
  77. displayProducts(){
  78. return this.state.prodList.map( (item,key) => {
  79. return(
  80. //display of products
  81. )
  82. })}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement