I am now writing an operating system that is written to hbase. The front end is vue.js, and the back end is node.js, database RT, is hbase. At present, my front-end can send data to the back-end to receive, but when writing, I always report an error.
Users/user/Desktop/web/node_modules/hbase/lib/row.js:169
return args[0].apply(this, [null, cells]);
TypeError: Cannot read property "apply" of undefined
at client.connection.get (/Users/user/Desktop/web/node_modules/hbase/lib/row.js:169:20)
at IncomingMessage.res.on (/Users/user/Desktop/web/node_modules/hbase/lib/connection.js:142:16)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1091:14)
at process._tickCallback (internal/process/next_tick.js:174:19)
node.js: can write to the database, but will stop the program and report the error above.
router.post("/uploadHbase", function(req, res){
var form = new formidable.IncomingForm();
form.parse(req, function (err, fields, files) {
console.log(fields);//postXXX
client.table("test2")
.create("col_family", function(err, success){
this
.row("rowkey1")
.put("col_family:model_contents", "testContent", function(err, success) {
this.get(fields.colFamilyPut, function (err, cells) {
this.exists(function (err, exists) {
assert.ok(exists);
});
});
});
});
});
res.json({
status:"0",
msg:"",
});
});
this can be run under the same route, and different routes are submitted
router.post("/upload", function(req, res){
var form = new formidable.IncomingForm();
form.uploadDir = path.join(__dirname, "/upload");
form.parse(req, function (err, fields, files) {
console.log(fields);//postXXX
fs.readFile(files.file.path, "utf8", (err, data) => {
if (err) {
console.log(err);
}
var obj = JSON.parse(data);
console.log(obj);
//Put to hbase
client.table( "test" )
.create("col_family", function(err, success){
this
.row("rowkey")
.put("col_family:model_contents", JSON.stringify(obj), function(err, success) {
this.get(fields.colFamilyPut, function (err, cells) {
this.exists(function (err, exists) {
assert.ok(exists);
console.log(success);
});
});
});
});
});
there is no problem with another post under the same route, and it can be written to the hbase database without knowing why.