我想将数据与python函数的问题和答案一起返回到表中

时间:2019-02-17 12:23:58

标签: python

exports.getUserBySlug = async (req, res, next) => {

  const user = await User.findOne({ slug: req.params.slug })
  let embed = {}
  if (!user) return next();

  axios.get(`https://soundcloud.com/oembed?format=json&url=${user.musicLink}`)
  .then(response => {
    embed = response.data
  console.log('1: ', embed)

  })
  .catch(error => {
    console.log(error);
  })

  console.log('2: ', embed)

  res.render('user', {
    user,
    title: user.name,
    embed: embed.html,
  });
};

我是python的新手,所以请明确答案 该代码在我要创建html表的html页面中生成json响应

0 个答案:

没有答案