09慕课网《进击Node.js基础(一)》HTTP-get/request

get是对request封装

可以在后台发起http请求,获取远程资源,更新或者同步远程资源

http.request(options[,callback])

 以下代码灌水失败:

var http = require('https')

var querystring = require('querystring')
//提交的表单数据Request Payload
var postData = querystring.stringify({
    "blogApp":"-beauTiFul",
    "body":"评论测试!!!",
    "parentCommentId":0,
    "postId":9102286,
})

var options = {
    //General
    hostname: 'www.cnblogs.com',
    port: 443,
    path: '/mvc/PostComment/Add.aspx',
    method: 'POST',
    //Request Headers
    headers:{
        //':authority':'www.cnblogs.com',
        //':method':'POST',
        //':path':'/mvc/PostComment/Add.aspx',
        //':scheme':'https',
        'accept':'application/json, text/javascript, */*; q=0.01',
        'accept-encoding':'gzip, deflate, br',
        'accept-language':'zh-CN,zh;q=0.8',
        'content-length':postData.length,
        'content-type':'application/json; charset=UTF-8',
        'cookie':'.CNBlogsCookie=6E153D1893CB37E731DB5EE8D21E661A7C049B5F3253BBF96697F61D3F80E228E35D96D67A0D9BCE96F2AC8BA8CEEBD3620CF8BF16272BA9F69993374453A28E325C7EBBD6F303CE4BE9A4AB4574AEC1F7659471; .Cnblogs.AspNetCore.Cookies=CfDJ8Gf3jjv4cttDnEy2UYRcGZ24spfp8lnfTvvwRTaSyrr3xil4hGj3F9ck-z2Jh14wCbuYEpPjN2je1GiahhBJmbD-DdW3GzYFsE8AG9O3BH9zjQClKJO72EMtqXW6Gf2wLLf_XjdRveKssOw_84c_DWFLC6pfSYzET8c4CKlkafKaq2Bhtd7f2o9KkA0vm5cCUqAQQ7YPrO1gspYwVIwnITYWBQ1yGnoQBSqjIXZek-Go6ipjFu4MHuIg-8uFogcSf6eWDSLe7v94cMmCEYdGF-4EccatEtxZbtcC7YdwRm4H; _ga=GA1.2.1898867304.1527349394; _gid=GA1.2.1085252201.1527349394; _gat=1',
        'origin':'https://www.cnblogs.com',
        'referer':'https://www.cnblogs.com/-beauTiFul/p/9102286.html',
        'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0',
        'x-requested-with':'XMLHttpRequest'
    }
}

var req = http.request(options,function(res){
    console.log('Status:' + res.statusCode)
    console.log('headers:' + JSON.stringify(res.headers))

    res.on('data',function(chunk){
        console.log(Buffer.isBuffer(chunk))
        console.log(typeof chunk)
    })

    res.on('end',function(){
        console.log('评论完毕')
    })

})

    req.on('error',function(e){
        console.log('Error:' + e.message)
    })

    req.write(postData)

    req.end()

 

转载于:https://www.cnblogs.com/-beauTiFul/p/9102286.html

ERROR in src/modules/data-map/data-table/assets-table-detail/blood/views/g6-blood-table.vue:37:14 TS2339: Property '$axios' does not exist on type 'CombinedVueInstance<Vue, object, object, object, Record<never, any>>'. 35 | if (isInit) { 36 | request = () => > 37 | vm.$axios | ^^^^^^ 38 | .$get(tableLineageBlood(tableId), { 39 | params: { 40 | upstreamLevel: 1, ERROR in src/modules/data-map/data-table/assets-table-detail/blood/views/g6-blood-table.vue:44:19 TS7006: Parameter 'res' implicitly has an 'any' type. 42 | }, 43 | }) > 44 | .then(res => res.payload) | ^^^ 45 | } else { 46 | request = () => 47 | vm.$axios ERROR in src/modules/data-map/data-table/assets-table-detail/blood/views/g6-blood-table.vue:47:14 TS2339: Property '$axios' does not exist on type 'CombinedVueInstance<Vue, object, object, object, Record<never, any>>'. 45 | } else { 46 | request = () => > 47 | vm.$axios | ^^^^^^ 48 | .$get(lineageBlood, { 49 | params: { 50 | nodeId: data.nodeId, ERROR in src/modules/data-map/data-table/assets-table-detail/blood/views/g6-blood-table.vue:55:19 TS7006: Parameter 'res' implicitly has an 'any' type. 53 | }, 54 | }) > 55 | .then(res => res.payload) | ^^^ 56 | } 57 | return request().then((payload: any) => { 58 | return { ERROR in src/modules/data-map/data-table/assets-table-detail/blood/views/g6-blood-table.vue:112:22 TS2339: Property '$router' does not exist on type 'CombinedVueInstance<Vue, object, object, object, Record<never, any>>'. 110 | value: data.dataCollectSuccess 111 | ? `<a class="tooltip-value primary" href="${ > 112 | vm.$router.resolve(`/data-map/data-table/${data.tableId}`).href | ^^^^^^^ 113 | }"> ${data.tableName} </a>` 114 | : data.tableName, 115 | }, FATAL Nuxt build error 09:02:49 at WebpackBundler.webpackCompile (node_modules/@nuxt/webpack/dist/webpack.js:1888:21) at async WebpackBundler.build (node_modules/@nuxt/webpack/dist/webpack.js:1853:5) at async Builder.build (node_modules/@nuxt/builder/dist/builder.js:249:5) at async ensureBuild (node_modules/@nuxt/cli/dist/cli-generate.js:117:3) at async Object.run (node_modules/@nuxt/cli/dist/cli-generate.js:234:7) at async NuxtCommand.run (node_modules/@nuxt/cli/dist/cli-index.js:356:7) ╭─────────────────────────────╮ │ │ │ ✖ Nuxt Fatal Error │ │ │ │ Error: Nuxt build error │ │ │ ╰─────────────────────────────╯
08-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值