为什么这段代码不起作用?我明白了
TypeError: $ is not a function
测试.js
'use strict';
var Promise = require('bluebird');
var request = require('request-promise');
var cheerio = require('cheerio');
module.exports = {
get: function () {
return new Promise(function (resolve, reject) {
var options = {
uri: 'https://www.example.com',
transorm: function (body) {
return cheerio.load(body);
}
};
request(options)
.then(function ($) {
// Error happens here
$('#mydivid').text();
resolve();
})
.catch(function (error) {
console.log(error);
reject(error);
});
});
}
}