brennenrocks / fishbowl-js Goto Github PK
View Code? Open in Web Editor NEWJavaScript wrapper for the Fishbowl API
JavaScript wrapper for the Fishbowl API
If there are commas in fields, such as ProductDescription - the import breaks everything after the comma. If the comma is escaped by replacing it with , it doesn't change anything.
Is there a method that should be used? I am now wrapping all fields in double quotes and that is working.
First of all.... amazing work. I have been playing around with fishbowl-js for a few days now and am starting to get somewhere!
I've hit a major brick wall and just can seem to get my head around how to parse the request into a html table in node js.
I have successfully set up an express server in node js using visual studio 2019 and when I go to localhost:3000 i get the data punched out in a response shown below:
{"statusCode":1000,"Rows":[{"PARTID":"2","LOCATIONGROUPID":"1","QTY":"1644.607500000","id":"2","num":"ICFASTORANGE","description":"4LT DIVIDER PAD #30.1"},{"PARTID":"4","LOCATIONGROUPID":"1","QTY":"662.977140000","id":"4","num":"EMPICOLXC","description":"GARDINOL XC"},{"PARTID":"5","LOCATIONGROUPID":"1","QTY":"827.718270000","id":"5","num":"EMPIGENBB","description":"GARDIQUAT BBAU"},{"PARTID":"6","LOCATIONGROUPID":"1","QTY":"3690.751500000","id":"6","num":"SLES70","description":"GARDILENE SQ70"},{"PARTID":"7","LOCATIONGROUPID":"1","QTY":"2381.650000000","id":"7","num":"CL24/410WHSCREW","description":"24/410 WHITE RIBBED SCREW CAP"},{"PARTID":"11","LOCATIONGROUPID":"1","QTY":"407.000000000","id":"11","num":"BANTTERMITEKILL","description":"PERMETHRIN 100 g/L"},{"PARTID":"17","LOCATIONGROUPID":"1","QTY":"990.000000000","id":"17","num":"CU500PETCLBELL","description":"500ML PET CLEAR BELL ROUND BOTTLE"},{"PARTID":"19","LOCATIONGROUPID":"1","QTY":"522.584100000","id":"19","num":"CITAC","description":"CITRIC ACID `FINE'"},{"PARTID":"23","LOCATIONGROUPID":"1","QTY":"140.512820000","id":"23","num":"CITACMONO","description":"CITRIC ACID MONOHYDRATE"},{"PARTID":"24","LOCATIONGROUPID":"1","QTY":"15.771000000","id":"24","num":"SODTHIOSULPH","description":"SODIUM THIOSULPHATE CRYSTAL"},{"PARTID":"31","LOCATIONGROUPID":"1","QTY":"768.000000000","id":"31","num":"FGLOCTHKORAN4LT","description":"ORANGE HAND CLEAN 36253"},{"PARTID":"32","LOCATIONGROUPID":"1","QTY":"5801.155020000","id":"32","num":"STARCHCORN/1","description":"CORN STARCH - FINE"},{"PARTID":"33","LOCATIONGROUPID":"1","QTY":"162.477600000","id":"33","num":"MAGCARB","description":"MAGNESIUM CARBONATE LIGHT"},{"PARTID":"34","LOCATIONGROUPID":"1","QTY":"4.587040000","id":"34","num":"JASMINEOILCO","description":"JASMINE OIL 3% JOJOBA CERTIFIED ORGANIC"},{"PARTID":"35","LOCATIONGROUPID":"1","QTY":"0.730080000","id":"35","num":"CHAMOILCO","description":"CHAMOMILE OIL ROMAN 3% JOJOBA CERTIFIED ORGANIC"},{"PARTID":"36","LOCATIONGROUPID":"1","QTY":"201.722530000","id":"36","num":"AVOCADOOILCO","description":"AVOCADO OIL CERTIFIED ORGANIC"},{"PARTID":"37","LOCATIONGROUPID":"1","QTY":"0.969410000","id":"37","num":"GERANIUMOILCO","description":"GERANIUM OIL (EGYPT) CERTIFIED ORGANIC"},{"PARTID":"39","LOCATIONGROUPID":"1","QTY":"2441.600000000","id":"39","num":"CL46WHITE/1","description":"WHITE BASE FOR COMPOSITE CAN"},{"PARTID":"47","LOCATIONGROUPID":"1","QTY":"16.674000000","id":"47","num":"PLFS68159","description":"MEDICATED FRAGRANCE"},{"PARTID":"53","LOCATIONGROUPID":"1","QTY":"86.000000000","id":"53","num":"OCPL12X125","description":"RING EZE 125ML X 12 PLAIN #168"},{"PARTID":"55","LOCATIONGROUPID":"1","QTY":"181.391600000","id":"55","num":"BANTTERMITEKILLER","description":"PERMETHRIN 250 G/L"},{"PARTID":"56","LOCATIONGROUPID":"1","QTY":"103.195230000","id":"56","num":"GAFQUAT755N","description":"GAFQUAT 755N-P"},{"PARTID":"57","LOCATIONGROUPID":"1","QTY":"231.650000000","id":"57","num":"CU250PVCCL","description":"250ML PVC CLEAR OVAL BOTTLE #391"},{"PARTID":"58","LOCATIONGROUPID":"1","QTY":"59.982000000","id":"58","num":"ROTDUST","description":"ROTENONE DUST 7%"},{"PARTID":"59","LOCATIONGROUPID":"1","QTY":"101.572600000","id":"59","num":"PROPGLY","description":"PROPYLENE GLYCOL USP/BP"},{"PARTID":"60","LOCATIONGROUPID":"1","QTY":"295.227128948","id":"60","num":"LACTICACID","description":"PURAC HS 88"},{"PARTID":"61","LOCATIONGROUPID":"1","QTY":"2749.500000000","id":"61","num":"LBRANTKILL1LTB","description":"ANT KILLER 1LT LABEL BACKS"},{"PARTID":"62","LOCATIONGROUPID":"1","QTY":"1510.600000000","id":"62","num":"LBRANTKILL750","description":"ANT KILL 750ml LABEL FRONTS"},{"PARTID":"63","LOCATIONGROUPID":"1","QTY":"710.600000000","id":"63","num":"LBRANTKILL750B","description":"ANT KILL 750ml LABEL BACKS"}, ect...
my code is as follows i have 2 files, one called app.js and another called index.js (code shown below):
app.js:
'use strict';
var debug = require('debug');
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/index');
var users = require('./routes/users');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
app.use('/users', users);
// catch 404 and forward to error handler
app.use(function (req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
// production error handler
// no stacktraces leaked to user
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});
app.set('port', process.env.PORT || 3000);
var server = app.listen(app.get('port'), function () {
debug('Express server listening on port ' + server.address().port);
});
index.js (code):
'use strict';
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get(hwtest(), (req, response) => {
const Fishbowl = require('fishbowl-js');
const fb = new Fishbowl({
host: 'localhost',
port: 28192,
IAID: 54321,
IAName: 'Fishbowljs',
IADescription: 'Fishbowljs helper',
username: 'test',
password: 'test',
useLogger: true
});
fb.sendRequest({ req: "LoginRq" });
fb.sendRequest(
{
req: "ExecuteQueryRq",
options: {
query: "select * from qtyonhand left join (select id, num, description from part) part on part.id=qtyonhand.PARTID"
}
},
(err, res) => {
if (err) {
return response.status(err, 500);
}
return response.json(res);
}
);
fb.sendRequest({ req: "LogoutRq" });
});
module.exports = router;
function hwtest() {
return "/";
}
I have tried so many tutorials and solutions on "stackoverflow to dispaly json from mysql/database as html table in node js" and have no luck.
Any help would be greatly appreciated
Hi,
I've been using this package for awhile now and it's been a huge help.
I'm currently running it on a Node/Express server and running into some stability issues that I've been trying to debug for a bit.
I'm getting response data via this.connection.on('data'...
but have recently noticed that the response is getting stuck waiting for resData.length === resLength.
I'm calling fb.sendRequest from an endpoint like this:
app.get("/products", (req, response) => {
fb.sendRequest({ req: "LoginRq" });
fb.sendRequest(
{
req: "ExecuteQueryRq",
options: {
query: "select * from product"
}
},
(err, res) => {
if (err) {
return response.status(err, 500);
}
return response.json(res);
}
);
});
I'm also seeing a bunch of previous requests in the reqQue that aren't being dequed and I'm wondering if that has something to do with this issue.
I'm new to fishbowl, thanks a ton for making this. I was playing around yesterday and wasn't able to initialize my instance properly. After digging in I discovered that the 'statusCode' was being returned inside of the response from fishbowl which was throwing off your switch case.
Not sure if this is just my instance of fishbowl, or what's up, but I was able to fix it by changing line 244 in index.ts from:
const fbData = Object.keys(data.FbiJson.FbiMsgsRs)[0];
to:
const fbData = Object.keys(data.FbiJson.FbiMsgsRs).find(msg => msg != 'statusCode');
I hope that helps anybody else running into this problem!
According to Fishbowl Support:
"In Fishbowl 21.12 we updated the encryption scheme we use for Fishbowl passwords and removed the requirement to send it as part of API calls. You'll just need to send the password as plain text and not MD5 hashed."
It looks like the login request function needs to change, but how to handle the different versions of Fishbowl with how this library is implemented?
Does the importrq return anything other than the Fishbowl response code? Is there a last imported id request that could be run instead?
Try to run fishbowl-js without starting the Fishbowl Server. It will hang and run out of memory.
When Fishbowl disconnects the connection due to inactivity, there is an infinite loop with the connectToFishbowl()
function.
It tries to connect but goes to an error where it tries to connect again.
The repeated error shows:
Error: connect EINVAL x.x.x.x:28192 - Local (0.0.0.0:22685)
at internalConnect (node:net:905:16)
at defaultTriggerAsyncIdScope (node:internal/async_hooks:431:18)
at GetAddrInfoReqWrap.emitLookup [as callback] (node:net:1051:9)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:8)
at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -4071,
code: 'EINVAL',
syscall: 'connect',
address: 'x.x.x.x',
port: 28192
}
Fishbowl Version: 21.5.20210513
Node Version: 14.17
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.