小编sma*_*ver的帖子

类型错误:require(...)不是SendGrid NodeJS中的函数

我正在尝试使用sendrid上的以下doc发送电子邮件:

https://sendgrid.com/docs/Integrate/Code_Examples/v2_Mail/nodejs.html

我的app.js看起来像这样:

var sendgrid = require('sendgrid')('SENDGRID_APIKEY');
Run Code Online (Sandbox Code Playgroud)

当runnig npm start时,我收到以下错误:

var sendgrid  = require('sendgrid')(conf);
                               ^
TypeError: require(...) is not a function
  at Object.<anonymous> (C:\Users\Grandullon\Desktop\angular\app.js:8:36)
  at Module._compile (module.js:409:26)
  at Object.Module._extensions..js (module.js:416:10)
  at Module.load (module.js:343:32)
  at Function.Module._load (module.js:300:12)
  at Module.require (module.js:353:17)
  at require (internal/module.js:12:17)
  at Object.<anonymous> (C:\Users\Grandullon\Desktop\angular\bin\www:7:11)
  at Module._compile (module.js:409:26)
  at Object.Module._extensions..js (module.js:416:10)
Run Code Online (Sandbox Code Playgroud)

我有什么想法我做错了吗?conf是我存储API密钥的变量.

我正在使用干净的快递安装.

谢谢

我的package.json可以按照要求在这里查看:

http://pastebin.com/pGKWFReX

node.js sendgrid express

1
推荐指数
1
解决办法
1572
查看次数

为什么我的if语句没有按照我期望的方式工作?

我试图实现以下目标:我使用SQL查询我的SQL数据库SELECT * FROM subjects.在这之后我要求使用数组mysqli_fetch_assoc.在那之前一切都很好.现在的问题是,当我尝试在每个循环中修改$ genero的值时,取决于它是1还是0.但是$ genero的值永远不会改变,它总是1并且我确信数组是0和1.任何想法,而$ genero的价值不会通过循环改变?

while ($subject = mysqli_fetch_assoc($result)) {
if ($subject["sexo"] = 1) { 
    $genero = "<img src='images/hombre.png' />";
} else {
    $genero = "<img src='images/mujer.png' />";
}
    echo $genero;
}
Run Code Online (Sandbox Code Playgroud)

php mysql if-statement

-1
推荐指数
1
解决办法
70
查看次数

标签 统计

express ×1

if-statement ×1

mysql ×1

node.js ×1

php ×1

sendgrid ×1