Jed1

Slider

Aug 17th, 2021
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. import React, {useState, useEffect} from 'react';
  2. import Slider from "react-slick";
  3.  
  4. import { AiOutlineArrowLeft, AiOutlineArrowRight } from "react-icons/ai";
  5. import './BannersWorks.css'
  6.  
  7.  
  8.  
  9. import SliderComp, {SliderData} from "./SliderData";
  10.  
  11.  
  12.  
  13.  
  14. import Carousel from 'react-elastic-carousel'
  15.  
  16.  
  17.  
  18.  
  19. import axios from 'axios'
  20.  
  21.  
  22.  
  23.  
  24. const Banners = () => {
  25.  
  26. const [data, setData]=useState([])
  27. const [imageIndex, setImageIndex] = useState(0);
  28. const [height, width] = useWindowSize();
  29.  
  30.  
  31. useEffect(async () => {
  32.  
  33.  
  34. var config = {
  35. method: 'get',
  36. url: '',
  37. headers: { }
  38. };
  39.  
  40. await axios(config)
  41. .then(function (response) {
  42. console.log("This is the response from the banners api", JSON.stringify(response.data.data[0]));
  43. let newarray = []
  44. let count = 0
  45. for (count in response.data.data){
  46.  
  47. newarray.push(response.data.data[count])
  48. count = count + 1
  49. }
  50.  
  51. const anotherarray = newarray.map(({banner_image_id, title}) => {
  52. return ({banner_image_id, title} )
  53.  
  54. })
  55.  
  56.  
  57. setData(anotherarray)
  58. console.log('this is the data', data)
  59.  
  60. // run test functions below here data from Slider COMPONENT
  61.  
  62. console.log("data from SLIDERCOMPONENT", SliderComp());
  63.  
  64.  
  65.  
  66. })
  67. .catch(function (error) {
  68. console.log(error);
  69. });
  70. }, [])
  71.  
  72.  
  73.  
  74.  
  75. return()
  76. }
Advertisement
Add Comment
Please, Sign In to add comment