From e4fd5ff65e4e70dafb2539a25b438fa625106ff0 Mon Sep 17 00:00:00 2001 From: Chris Horne Date: Mon, 18 Mar 2024 13:36:46 -0700 Subject: [PATCH] Add Async function --- index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 5d6a968..f949445 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,21 @@ require('dotenv').config(); // Print out value of API key stored in .env file -console.log(process.env.API_KEY) \ No newline at end of file +console.log(process.env.API_KEY) + +const endpoint = 'https://api.giphy.com/v1/gifs/search?api_key=yokpNayCr4hqSrtPXiKgXjxG4NiDA1yP&q=${query}&limit=25&offset=0&rating=g&lang=en&bundle=messaging_non_clips' + +async function getImage(query) { + const response = await fetch(`https://api.giphy.com/v1/gifs/search?api_key=yokpNayCr4hqSrtPXiKgXjxG4NiDA1yP&q=${query}&limit=2&offset=0&rating=g&lang=en&bundle=messaging_non_clips`); + + // console.log(response) + + const data = await response.json(); + + const url = data.data[1].url + + console.log(url); +} + + +getImage('dogs') \ No newline at end of file