Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
I received Object(...) is not a function when I use useGetCryptoNewsQuery from api and try to console.log(cryptoNews)

I try to console.log the data I've been receiving from RAPID API bing news, but when I tried to pull it out, it says Object(...) is not a function. When I try to remove the line 6 of News.js it renders, but if I put it back it returns the same problem

News.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 News

store.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 } = cryptoNewsApi

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I believe Automatic Semicolon Process doesn't happen. Try inserting a semicolon at the end of the statement.

const { data: cryptoNews} = useGetCryptoNewsQuery({newsCategory: 'Cryptocurrency', count: simplified ? 6 : 12});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!