Im connecting to a star wars api and trying to return a string with all the data, but its getting returned as undefined, but when i console.log it, it works
https = require('https')
url = 'https://swapi.co/api/people/'
getCharacters = () => {
https.get(url, response => {
let body = ''
response.on('data', data => {
json = data.toString()
body += json
})
response.on('end', () => {
data = JSON.parse(body)
let nextLink = data.next
return nextLink
})
})
}
console.log(getCharacters())
im expecting it to return a string with all the data but its getting returned as undefined