Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持Async / Await、Promise #4

Open
borie88 opened this issue Aug 21, 2018 · 10 comments
Open

支持Async / Await、Promise #4

borie88 opened this issue Aug 21, 2018 · 10 comments

Comments

@borie88
Copy link

borie88 commented Aug 21, 2018

框架可不可以支持es6/7比较新的语法?使用callback现在已经不是很标准的吧。
希望语法可以是这样:
const res = await ssender.sendWithParam(countryCode, phoneNumber, templateId, params, "", "")

@HarryQQ
Copy link

HarryQQ commented Sep 22, 2018

使用sync-request替换https.request可以解决。

框架可不可以支持es6/7比较新的语法?使用callback现在已经不是很标准的吧。
希望语法可以是这样:
const res = await ssender.sendWithParam(countryCode, phoneNumber, templateId, params, "", "")

我有同样的困惑,后来使用sync-request替换https.request解决了

@qcloudsms
Copy link
Owner

@borie88 @HarryQQ 考虑到对现有用户兼容问题,这个我们暂时不能升级,不过改造应该比较简单,辛苦自己fork调整一下

@Lucky-dj
Copy link

Lucky-dj commented Dec 18, 2018

const QcloudSms = require("qcloudsms_js");

sendWithParam(phoneNumbers, templateId, params) {
    const qcloudsms = QcloudSms(appid, appkey);
    const msender = qcloudsms.SmsMultiSender();
    return new Promise((resolve, reject) => {
      msender.sendWithParam('86', phoneNumbers, templateId, params, '', '', '', (err, res, resData) => {
        if (err) {
          reject(err);
        } else {
          resolve({
            resData,
            req: res.req,
          });
        }
      });
    });
  }

@shiny
Copy link

shiny commented Mar 23, 2019

@borie88 @HarryQQ 考虑到对现有用户兼容问题,这个我们暂时不能升级,不过改造应该比较简单,辛苦自己fork调整一下

可以在未传 callback 参数时自动 return 一个Promise

@willin
Copy link

willin commented May 5, 2019

mark

@xyzwps
Copy link

xyzwps commented Nov 22, 2019

@borie88 @HarryQQ 考虑到对现有用户兼容问题,这个我们暂时不能升级,不过改造应该比较简单,辛苦自己fork调整一下

老用户不想升级可以用老版本啊

@xyzwps
Copy link

xyzwps commented Nov 22, 2019

@borie88 @HarryQQ 考虑到对现有用户兼容问题,这个我们暂时不能升级,不过改造应该比较简单,辛苦自己fork调整一下

可以在未传 callback 参数时自动 return 一个Promise

这个就是懒

@willin
Copy link

willin commented Nov 22, 2019

.... 嗯

升个大版本号就行了。

@willin
Copy link

willin commented Nov 27, 2019

const QcloudSms = require("qcloudsms_js");

sendWithParam(phoneNumbers, templateId, params) {
    const qcloudsms = QcloudSms(appid, appkey);
    const msender = qcloudsms.SmsMultiSender();
    return new Promise((resolve, reject) => {
      msender.sendWithParam('86', phoneNumbers, templateId, params, '', '', '', (err, res, resData) => {
        if (err) {
          reject(err);
        } else {
          resolve({
            resData,
            req: res.req,
          });
        }
      });
    });
  }

可以直接用 promisify

@xyzwps
Copy link

xyzwps commented Dec 2, 2019

没有安全风险的话,估计是没有人再维护这个库了。现在腾讯有新库了:tencentcloud-sdk-nodejs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants