As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
TypeError when trying to update entity in data store
k
karimsa
started a topic
about 9 years ago
Hi, guys.
I've ran into a problem where (occasionally, not always) my endpoint throws a BLRuntimeError with the debug message `TypeError: Cannot call method 'call' of undefined`. I tried inserting some log statements to lower down the problem to a single line, and it seems to be when I do a .update() on a collection. My code looks similar to this:
```
var onRequest = function (req, res, mods) {
var ds = mods.collectionAccess.collection('dsdb');
ds.findOne({ _id: req.body._id }, function (err, dsrow) {
if (!err && !!dsrow) {
dsrow.prop = req.body.val;
ds.update(dsrow, function () {
res.body = 'Updated data successfully';
res.complete(200);
});
}
});
};
```
I find it strange that the error only occurs sometimes, and it is not caught by a try/catch statement around my entire endpoint.
Karisma, I am trying to clarify if this is the code you are using, or like you said this is "similar" to the code you are using.
k
karimsa
said
about 9 years ago
This is similar. I can't disclose the actual code due to some confidentiality issues.
C
Caroline
said
about 9 years ago
Okay, so I am assuming that you're using shorthand for some of your code? Like res.complete is actually response.complete in your code?
k
karimsa
said
about 9 years ago
Yes, and req is request and mods is modules.
C
Caroline
said
about 9 years ago
Hey Karisma,
The callback requires three arguments; error, response, and body. See also http://devcenter.kinvey.com/rest/reference/business-logic/reference.html#collection-access-module
karimsa
I've ran into a problem where (occasionally, not always) my endpoint throws a BLRuntimeError with the debug message `TypeError: Cannot call method 'call' of undefined`. I tried inserting some log statements to lower down the problem to a single line, and it seems to be when I do a .update() on a collection. My code looks similar to this:
```
var onRequest = function (req, res, mods) {
var ds = mods.collectionAccess.collection('dsdb');
ds.findOne({ _id: req.body._id }, function (err, dsrow) {
if (!err && !!dsrow) {
dsrow.prop = req.body.val;
ds.update(dsrow, function () {
res.body = 'Updated data successfully';
res.complete(200);
});
}
});
};
```
I find it strange that the error only occurs sometimes, and it is not caught by a try/catch statement around my entire endpoint.
All comments are appreciated! Thanks.