• 周四. 4月 25th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

nodejs 通过 get获取数据修改redis数据

admin

11月 28, 2021

如下代码是没有报错的正确代码 我通过https获取到数据 想用redis set一个键值存储 现在我掉入了回调陷阱
res.on 里面接收到的数据是data 里面如果放入 client.on(‘connect’,functi …这个修改函数就会报错。

'use strict';
var redis = require('redis'),
    RDS_PORT = 6379,        //端口号
    RDS_HOST = '127.0.0.1',    //服务器IP
    //RDS_PWD = 'porschev',    //密码    
    RDS_OPTS = {},            //设置项
    client = redis.createClient(RDS_PORT,RDS_HOST,RDS_OPTS);
/*client.auth(RDS_PWD,function(){
    console.log('通过认证');
});*/
var https = require('https');

https.get('https://encrypted.google.com', (res) => {
  //console.log('statusCode:', res.statusCode);
  //console.log('headers:', res.headers);

  res.on('data', (data) => {
    //process.stdout.write(d);
    //如果这里写client.on就会报错 
    
  });

}).on('error', (e) => {
  console.error(e);
});


client.on('connect',function(){
        //console.log(data);
        client.set('author', 'Wilson',redis.print);
        client.get('author', redis.print);
        console.log('connect');
    });


client.on('ready',function(err){
    console.log('ready');
});

nodejs 通过 get获取数据修改redis数据 >> node.js

这个答案描述的挺清楚的:
http://www.goodpm.net/postreply/node.js/1010000008230652/nodejs通过get获取数据修改redis数据.html

《nodejs 通过 get获取数据修改redis数据》有3个想法
  1. EndoPump is a dietary supplement for men’s health. This supplement is said to improve the strength and stamina required by your body to perform various physical tasks. Because the supplement addresses issues associated with aging, it also provides support for a variety of other age-related issues that may affect the body. https://endopumpbuynow.us/

  2. Wow, awesome blog format! How long have you been running
    a blog for? you made blogging look easy. The whole look of your site
    is magnificent, let alone the content! You can see similar here sklep

  3. Hello! Do you know if they make any plugins to assist with Search Engine Optimization?
    I’m trying to get my site to rank for some targeted keywords but I’m not seeing very good results.
    If you know of any please share. Many thanks! You can read similar art here: Link Building

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注