Intento consolar. registrar los datos que he estado recibiendo de RAPID API bing news, pero cuando traté de extraerlos, dice que Object(...) no es una función. Cuando trato de eliminar la línea 6 de News.js, aparece, pero si la vuelvo a colocar, vuelve el mismo problema.
Noticias.js
import { Select, Typography } from 'antd' import { useGetCryptoNewsQuery } from '../services/cryptoNewsApi' const {Text, Title} = Typography const { Option } = Select const News = ({simplified}) => { const { data: cryptoNews} = useGetCryptoNewsQuery({newsCategory: 'Cryptocurrency', count: simplified ? 6 : 12}) console.log(cryptoNews) return( <div> <h1>Hello</h1> </div> ) } export default Newstienda.js
import { configureStore } from '@reduxjs/toolkit' import { cryptoApi } from '../services/cryptoApi' import { cryptoNewsApi } from '../services/cryptoNewsApi' export default configureStore({ reducer: { [cryptoApi.reducerPath]: cryptoApi.reducer, [cryptoNewsApi.reducerPath]: cryptoNewsApi.reducer, }, })cryptoNewsApi.js
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/dist/query' const cryptoNewsHeaders = { 'x-bingapis-sdk': 'true', 'x-rapidapi-host': 'bing-news-search1.p.rapidapi.com', 'x-rapidapi-key': 'API-KEY', } const baseUrl = 'https://bing-news-search1.p.rapidapi.com' const createRequest = (url) => ({ url, headers: cryptoNewsHeaders }) export const cryptoNewsApi = createApi({ reducerPath: 'cryptoNewsApi', baseQuery: fetchBaseQuery({ baseUrl }), endpoints: (builder) => ({ getCryptoNews: builder.query({ query: ({ newsCategory, count }) => createRequest( `/news/search?q=${newsCategory}&safeSearch=Off&textFormat=Raw&freshness=Day&count=${count}` ), }), }), }) export const { useGetCryptoNewsQuery } = cryptoNewsApiCreo que el proceso automático de punto y coma no sucede. Intente insertar un punto y coma al final de la declaración.
const { data: cryptoNews} = useGetCryptoNewsQuery({newsCategory: 'Cryptocurrency', count: simplified ? 6 : 12});