Node.js嬉皮API测试模块安装
16lz
2021-01-22
I am trying to install hippie api testing module. However, I keep getting an error when I try to run a simple script with hippie.
我正在尝试安装hippie api测试模块。但是,当我尝试使用hippie运行一个简单的脚本时,我一直收到错误。
I did: npm install hippie
我做了:npm安装嬉皮士
And created a file called: search.js
并创建了一个名为:search.js的文件
The code inside search.js is as simple as this:
search.js中的代码就像这样简单:
var api = require('hippie');
hippie()
.json()
.get('https://api.github.com/users/vesln')
.expectStatus(200)
.end(function(err, res, body) {
if (err) throw err;
});
And I run: node search.js
我运行:node search.js
It keeps getting me an error says
它不断给我一个错误说
ReferenceError: hippie is not defined
Any idea?
1 个解决方案
#1
1
You saved the reference to the hippie
module in variable named api
. Either use the api
variable or rename it.
您在名为api的变量中保存了对hippie模块的引用。使用api变量或重命名它。
var hippie = require('hippie');
hippie()
.json()
.get('https://api.github.com/users/vesln')
.expectStatus(200)
.end(function(err, res, body) {
if (err) throw err;
});
Or:
var api = require('hippie');
api()
.json()
.get('https://api.github.com/users/vesln')
.expectStatus(200)
.end(function(err, res, body) {
if (err) throw err;
});
更多相关文章
- Python和Visual Studio需要安装Node.js模块(Superfeedr Node.js包
- 将对象值传递给指令而不是任何其他数据变量
- 关于JavaScript变量声明及其初始化的问题
- 如何使用变量填充iframe源?
- 使用JavaScript多态在子类中创建唯一变量而不覆盖
- javascript入门笔记(1)——变量和计算
- 从单击使用属性作为变量进行AJAX调用。
- AngularJS错误:模块ngAnimate不可用
- 在JavaScript中访问PHP变量[重复]