How do I return a string from my async function using the request API?

by Mark   Last Updated September 14, 2019 21:26 PM

What I am trying to do is print the HTML code source as a sting using the request API, I've declared a function that fetches the data as a string put when I print the output, it returns undefined. I can't figure out what I'm doing wrong.

const request = require('request');

var test = getMovieTitles();
var output;

test.then(function(result) {
    output = result;

//prints undefined

async function getMovieTitles(){
    return new Promise(function(resolve, reject) {
    request('',function nes(err, res, body) {  

Related Questions

Why clearInterval doesn't work on a function

Updated July 21, 2017 14:26 PM