This commit is contained in:
mgabdev 2020-04-02 00:07:47 -04:00
parent 80d41b8d94
commit d79133c72d
3 changed files with 20 additions and 4 deletions

View File

@ -0,0 +1,16 @@
# frozen_string_literal: true
class Api::V1::GifsController < Api::BaseController
respond_to :json
skip_before_action :set_cache_headers
def index
uri = URI('https://api.tenor.com/v1/categories')
params = { :key => "QHFJ0C5EWGBH" }
uri.query = URI.encode_www_form(params)
res = Net::HTTP.get_response(uri)
render json: res.body if res.is_a?(Net::HTTPSuccess)
end
end

View File

@ -1,4 +1,4 @@
import axios from 'axios'
import api from '../api';
import { me, tenorkey } from '../initial_state'
export const GIFS_CLEAR_RESULTS = 'GIFS_CLEAR_RESULTS'
@ -14,13 +14,12 @@ export const GIF_CATEGORIES_FETCH_SUCCESS = 'GIF_CATEGORIES_FETCH_SUCCESS'
export const GIF_CATEGORIES_FETCH_FAIL = 'GIF_CATEGORIES_FETCH_FAIL'
export const fetchGifCategories = () => {
return function (dispatch) {
return function (dispatch, getState) {
if (!me) return
dispatch(fetchGifCategoriesRequest())
axios.get(`https://api.tenor.com/v1/categories?media_filter=minimal&limit=30&key=${tenorkey}`)
.then((response) => {
api(getState).get('/api/v1/gifs').then(response => {
console.log("fetchGifCategoriesSuccess:", response)
dispatch(fetchGifCategoriesSuccess(response.data.tags))
}).catch(function (error) {

View File

@ -328,6 +328,7 @@ Rails.application.routes.draw do
resources :streaming, only: [:index]
resources :custom_emojis, only: [:index]
resources :gifs, only: [:index]
resources :suggestions, only: [:index, :destroy]
resources :scheduled_statuses, only: [:index, :show, :update, :destroy]
resources :preferences, only: [:index]