Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class NSInventory extends React.Component{
- constructor(props){
- super(props);
- this.state = {
- prodList:[],
- storeList:[]
- };
- this.componentDidMount = this.componentDidMount.bind(this);
- this.getProducts = this.getProducts.bind(this);
- this.getStoreByCode = this.getStoreByCode.bind(this);
- }
- getProducts() {
- return(
- axios.post(API_URL, {
- query: `query{
- allProducts{
- name
- type
- quantity
- cost
- }
- }`
- }).then(res => {
- this.setState({
- prodList:res.data.data.allProducts
- })
- })
- )
- };
- getStoreByCode() {
- return(
- axios.post(API_URL, {
- query: `query{
- storeByCode(code: ${2})
- {
- code
- name
- type
- owner
- ubication
- dates
- description
- img
- }
- }`
- }).then(res => {
- var dict = res.data.data.storeByCode
- var array = []
- for(var key in dict) {
- var value = dict[key];
- array.push(value)
- }
- console.log(array)
- this.setState({
- storeInfo: array
- })
- })
- )
- };
- componentDidMount(){
- getProducts();
- getStoreByCode();
- };
- displayStoreDetails(){
- //display of store details
- )
- }
- displayProducts(){
- return this.state.prodList.map( (item,key) => {
- return(
- //display of products
- )
- })}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement