Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

113
Visualizações
not able to receive data in providers

I am trying to make a login page using nextjs and spotify js but encountering following error

error encoutered

Below is the following code

import React from 'react'
import { getProviders , signIn } from "next-auth/react"

function Login({ providers }) {
    return (
        <div>
           

            {Object.keys(providers).map((provider) => {
                <button>Login With {provider.name}</button>
            })}
        </div>
    )
}

export default Login;


export async function getServerSideProps() {
    const providers = await getProviders()
    
    return {
        props : {
            providers,
        }
    }
}

AND below is the code for providers in [...nextauth].js

export default NextAuth({
    // Configure one or more authentication providers
    providers: [
        SpotifyProvider({
            clientId: process.env.NEXT_PUBLIC_CLIENT_ID,
            clientSecret: process.env.NEXT_PUBLIC_CLIENT_SECRET,
            authorization: LOGIN_URL,
        }),
        // ...add more providers here
    ],
})


       
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

How I see it:

import React from 'react'
import { getProviders , signIn } from "next-auth/react"

function Login({ providers }) {
    return (
        <div>
           

            {providers.map((provider) => {
                <button>Login With {provider.name}</button>
            })}
        </div>
    )
}

export default Login;


export async function getServerSideProps() {
    const providers = await getProviders()
    //check if you have some data here
    console.log(providers)

    return {
        props : {
            providers: providers,
        }
    }
}
about 4 years ago · Juan Pablo Isaza Relatório

0

Make sure your nextjs api pointed to current hosting URL. For example : http://localhost:3000. Otherwise it will not work!

about 4 years ago · Juan Pablo Isaza Relatório

0

I'm guessing that either you didn't get any providers or your providers object is undefined on initial render. You can use Object.keys(providers || {}) instead to make sure it's always an object.

Also, Object.keys returns a string array of keys on the object meaning that the provider will be a string and won't have a name property. If you're iterating over the Object.keys you would need to use providers[provider].name instead of provider.name

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda