From f7547c3e1fb80827427cd4ad1dbe710ff6a9304e Mon Sep 17 00:00:00 2001 From: L-sampson Date: Thu, 5 Oct 2023 15:01:32 -0400 Subject: [PATCH 1/2] Steps 1-3 of getImage(query) function --- index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5d6a968..93a1784 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,11 @@ require('dotenv').config(); - +async function getImage(query){ + const endpoint = `https://api.giphy.com/v1/gifs/search?api_key=${process.env.API_KEY}&q=dogs&limit=25&offset=0&rating=g&lang=en` + const response = await fetch(endpoint); + const giphy = await response.json(); + console.log(giphy); +} +//Test giphy image +getImage('dogs'); // 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) \ No newline at end of file From 92858d777928ddbce1b95c4fcfb701d605fc0ee9 Mon Sep 17 00:00:00 2001 From: Michael Vela Date: Fri, 6 Oct 2023 10:09:32 -0500 Subject: [PATCH 2/2] index js from yesterday 10/5 --- index.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 93a1784..4ff15d6 100644 --- a/index.js +++ b/index.js @@ -1,11 +1,17 @@ require('dotenv').config(); async function getImage(query){ - const endpoint = `https://api.giphy.com/v1/gifs/search?api_key=${process.env.API_KEY}&q=dogs&limit=25&offset=0&rating=g&lang=en` + try{ + const endpoint = `https://api.giphy.com/v1/gifs/search?api_key=${process.env.API_KEY}&q=${query}&limit=25&offset=0&rating=g&lang=en` const response = await fetch(endpoint); const giphy = await response.json(); - console.log(giphy); + // console.log(giphy.data.images); + return giphy; + } + catch (error){ + console.log(error) + } } //Test giphy image -getImage('dogs'); +console.log(getImage('birds')); // 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) \ No newline at end of file