I do not understand how to chain promises:
getUser
is a promise function and also search
is a promise function. getUser
will return a language value.
With this data is not an array value, which should be returned by the search
function
getUser(userId)
.then(({ language }) => {
const data = search('content', language)
res.send(200, {
content: data,
user: { language }
})
})
.catch((error) => next(error))