diff --git a/src/contributor/index.js b/src/contributor/index.js index be3dfb4..0a8fe77 100644 --- a/src/contributor/index.js +++ b/src/contributor/index.js @@ -15,6 +15,7 @@ import RandomKanji from "./random-kanji"; import RandomPixelMonstersImage from "./random-pixel-monsters-image"; import RandomAiArtImage from "./random-ai-art"; import RandomQuotesApi from "./random-quote"; +import RandomTestimonial from "./random-testimonial"; export const data_contributor = [ RandomFoxImage, @@ -34,4 +35,5 @@ export const data_contributor = [ RandomPixelMonstersImage, RandomAiArtImage, RandomQuotesApi, + RandomTestimonial ]; diff --git a/src/contributor/random-testimonial.js b/src/contributor/random-testimonial.js new file mode 100644 index 0000000..4e2d4dd --- /dev/null +++ b/src/contributor/random-testimonial.js @@ -0,0 +1,77 @@ +import { useState, useEffect } from "react"; +import axios from "axios"; +import { Card } from "../components"; + +// avatar can get from here(avatar_url) +// https://api.github.com/users/akimabs + +const RandomTestimonial = () => { + const [data, setData] = useState(false); + + const getRandomTestimonial = async () => { + const response = await axios.get("https://testimonialapi.toolcarton.com/api/1"); + try { + if (response.status === 200) { + setData(response.data); + } + } catch (error) { + throw Error("Error while fetching", error); + } + }; + + useEffect(() => { + getRandomTestimonial(); + }, []); + + return ( + +
+ + + +

{data.message}

+
+ avatar + + {data.name} + {data.designation} + +
+
+ ); +}; + +export default RandomTestimonial;