Giter Site home page Giter Site logo

giphyapi's Introduction

##Giphy API

##Purpose The purpose of this day project is practice doing API calls using jQuery.

##Directions Fork and clone this repository. Complete all of the following steps. When you have finished, push your code into GitHub.

  • Review the code that is already built in your folder. I have provided the HTML and CSS structure for you.

  • Call in your jQuery CDN in the index.html file

  • Create and call in an app.js file in the index.html file

  • In the app.js file, setup your environment so that the page loads prior to running any JavaScript or jQuery code. (Hint: Use $(document).ready())

  • Set up a GET API request using the $.ajax({method: "GET", url: "API url"}) syntax

  • Look up the API url needed to complete this request on Giphy API and plug it into the url key in the API object.

  • After you have set up the request, create a .done promise with a callback function referencing the response as a parameter.

  • Using some JavaScript logic, loop through the array of objects, and append the object image urls using jQuery. If you are having a hard time figuring out what keys in the giphy objects should be used, console.log the objects and navigate through them so you can see the structure of the objects. When you have successfully appended the img tags, you should start seeing the funny cat giphys pop up on your view!

  • Currently, the giphys are popping up unprompted, so we should create a function that tells jQuery to perform the API request. Using the submit button in our html, let's have an event listener, using jQuery, listen for when we click the submit button, and tell it to run our function.

  • At this stage, we haven't yet told JavaScript what kind of giphys we want to see. In order to do this, we will have to call into our function the value of the input box. You should be able to accomplish this using some vanilla JavaScript.

  • When you get the function to call in your input value, you will still need to update the API url that we are using. If you look at it closely, there is a query segment that we will need to change based on our input. search?q=funny+cat You will need to replace the "funny+cat" part of the query. Using the input parameter, concatenate a new url that includes the input value in place of the funny cat.

  • And finally, if you have everything working and you try to select a new giphy input, the code you have written will just append your new results to the bottom of the page. If you want to get rid of your old search results when you go to search something new, you will have to run some jQuery in the top of the function that removes the gifList class, and then in order for the code to append properly, you will have to reappend the deleted div with a class of gifList.

  • Congratulations! You have completed your first API app. This will be very useful when creating servers and loading information to a database.

##Continued Practice

If you need more practice, try to create a new app, pulling information from another API. Or if you would like to fine tune the app we made today, it would be good HTML,CSS,JS, and jQuery practice.

##Copyright

(c) Montana Code School, 2016.

giphyapi's People

Contributors

npm1514 avatar kevingrastorf avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.