首页
学习
活动
专区
圈层
工具
发布
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    Express4.x API (三):Response (译)

    (这句话翻译过来我有些不理解,我就不再翻译,res.end用于结束响应) 快速结束响应而无需任何数据,如果你需要对数据进行响应,取而代之的是使用诸如res.send和res.json res.send(...]) 发送http响应 body参数可以是一个buffer对象,字符串,对象,数组.举个栗子: res.send(new Buffer('whoop')) res.send({some:'json'}...) res.send('some html') res.status(404).send('sorry,er can not find that!')...res.status(500).send({error:'something brew up'}) 当参数是一个buffer对象时,该方法设置Content-Type响应头字段为application/...当参数为字符串时,这个方法设置'Content-Type'为'text/html' res.send('some html') 当参数为数组或者对象时,Express用JSON表示响应 res.send

    1.9K100
    领券