Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const apiKey = '&api_key=N8TVb2yjw9q5DG5Us8Zs9bqM33UF3QU5';
- const baseUrl = 'http://api.giphy.com/v1/gifs';
- const uploadUrl = `http://upload.giphy.com/v1/gifs?${apiKey}`;
- const getTrendingGifs = async () => {
- const response = await fetch(`${baseUrl}/trending?${apiKey}`);
- const trendingGifs = await response.json();
- return trendingGifs;
- };
- const uploadGif = async (data) => {
- const response = await fetch(uploadUrl, {
- method: 'POST',
- mode: 'no-cors',
- header: {
- 'Access-Control-Allow-Origin': '*',
- 'Content-Type': 'multipart/form-data',
- },
- body: data
- });
- return response;
- };
- const getSearchedGifs = async (searchStr) => {
- const response = await fetch(`${baseUrl}/search?${apiKey}&q=${searchStr}`);
- const searchedGifs = await response.json();
- return searchedGifs;
- };
- const getUploadedGifs = async () => {
- // TODO
- };
- const getGifById = async () => {
- // TODO
- };
- const getRandomGifId = async () => {
- // TODO
- };
- const getRandomGifs = async () => {
- // TODO
- };
- export {
- getTrendingGifs,
- uploadGif,
- getSearchedGifs,
- getUploadedGifs,
- getGifById,
- getRandomGifId,
- getRandomGifs,
- };
Advertisement
Add Comment
Please, Sign In to add comment