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

106
Views
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
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!