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

116
Visualizações
Including a body in useMutate using restful react

I am learning restful-react and trying to use the useMutate feature as a POST request but I need to include a payload. I see in the documentation there is the options to mock data to the console but Im not sure of how I can I actually include the data to send to the backend?

this is an example of my request:

const { mutate: hitLogger } = useMutate({
    path: API_URL_LOGGER,
    verb: 'POST',
    requestOptions: {
      headers: {
        ...API_BASE_HEADERS,
        Authorization: `Bearer ${userToken}`,
      },
    },
    mock: {
      error: error,
    },
  })

useEffect(() => {
 
if(error){
      hitLogger()
    }
  }, [error])

Do I need to send the error as a param to the hitLogger function?

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

0

I figured it out. The body is passed as a param when the function is called and the request Post it so the proper way to do it is like this:

const { mutate: hitLogger } = useMutate({
    path: API_URL_LOGGER,
    verb: 'POST',
    requestOptions: {
      headers: {
        ...API_BASE_HEADERS,
        Authorization: `Bearer ${userToken}`,
      },
    },
    mock: {
      error: error,
    },
  })

useEffect(() => {
 
if(error){
      hitLogger({
       data: {data: data}
        )
    }
  }, [error])
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