Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

110
Vistas
Why is POST request showing undefined? Node JS

I am receiving a request response in the console.log, however when I try to post to Mastodon (similar site to Twitter), it posts as 'undefined'.

bot.js:

require('dotenv').config();
const Mastodon = require('mastodon-api');
var request = require('request');

console.log("Mastodon Bot starting...");

const M = new Mastodon({
    access_token: process.env.ACCESS_TOKEN,
    client_key: process.env.CLIENT_KEY,
    client_secret: process.env.CLIENT_SECRET,
    timeout_ms: 60*1000,
    api_url: 'https://botsin.space/api/v1/',
  })

  const options = {
    method: 'GET',
    url: 'https://apisite.com/steps',
    qs: {count: '3'},
    headers: {
      'X-RapidAPI-Key': 'secret-api-key',
      'X-RapidAPI-Host': 'site-host',
      useQueryString: true,
    },
  };

  request(options, function (error, response, body) {
    if (error) throw new Error(error);
    console.log(JSON.parse(body, undefined, 5));

  });
    const params = {
      status: request
    }

    M.post('/statuses', params, (error, params) => {
    if (error) {
        console.log(error);
    }
    else {
        console.log(params.request);
    }
    });

This posts "Mastodon bot is starting...", then the results of the API GET request to the console (the response body). However, it does not post the response body to /statuses in Mastodon itself, it just posts 'undefined'.

How can I post the response body that I get in the console, to Mastodon?

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda