buffer.js:238
buf.copy(buffer, pos);
^
TypeError: buf.copy is not a function
at Function.Buffer.concat (buffer.js:238:9)
I am getting this error,when I try to include backbone.localstorage
Related
I am trying to delete the last message sent by my bot (just to keep then channels clean) but when I define lM as channel.send("Test") lM.delete() returns lM.delete() is not a function.
Here is my code:
async function sendMsg(content){
return await message.channel.send(content)
}
LM = sendMsg("Test")
LM.delete()
and this is my error:
LM.delete()
^
TypeError: LM.delete is not a function
at C:\Users\willi\Documents\Discord-bot\main.js:167:30
Node.js v17.4.0
I have found the problem, the function was returning a promise, so I just had to do LM.Message.delete().
I'm having an issue in gRPC that's been driving me crazy. I have a .NET gRPC service that my ReactJS client is connecting to - this works fine. I'm subscribing to my stream, and I get data over the stream as expected. I'm having an issue deserializing "google.protobuf.Any" types that exist in my messages. The one I'm receiving looks like this:
message PointNotification {
KindsOfPointNotification Kind = 1;
google.protobuf.Any NotificationData = 2;
}
Inside of the ReactJS client I am doing the following:
useEffect(() => {
console.log("Subscribing to point stream");
var pointStream = client.subscribeToNotificationStream(new Empty(), {});
pointStream.on("data", (response) => {
switch (response.getKind())
{
case KindsOfPointNotification.KINDS_OF_POINT_NOTIFICATION_POINT_ADDED_OR_UPDATED:
const any = response.getNotificationdata();
console.log(any);
const bar = any.unpack(NotificationPointAddedOrUpdated.deserializeBinary, any.getTypeName());
console.log(bar);
break;
case KindsOfPointNotification.KINDS_OF_POINT_NOTIFICATION_POINT_REMOVED:
console.log("Point removed");
break;
}
});
The "any" variable looks right in the browser logs. The payload, and the typeName are correct. However when I go to unpack "any" I get the following error (screenshot):
TypeError in browser
Uncaught TypeError: deserialize is not a function
This is despite the fact that the generated _pb file has the following method:
/**
* Deserializes binary data (in protobuf wire format).
* #param {jspb.ByteSource} bytes The bytes to deserialize.
* #return {!proto.Point.NotificationPointAddedOrUpdated}
*/
proto.Point.NotificationPointAddedOrUpdated.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.Point.NotificationPointAddedOrUpdated;
return proto.Point.NotificationPointAddedOrUpdated.deserializeBinaryFromReader(msg,
reader);
};
According to The documentation this is correct way to do it. What am I missing? Why am I getting a deserialize error?
Edit: I have one other thing to add. If I change the following line:
const bar = any.unpack(NotificationPointAddedOrUpdated.deserializeBinary, any.getTypeName());
To:
const bar = any.unpack(NotificationPointAddedOrUpdated.deserializeBinary(), any.getTypeName());
The error I get in the browser changes to:
Uncaught TypeError: _proto_pointdata_pb_js__WEBPACK_IMPORTED_MODULE_3___default(...).deserializeBinary is not a function
The following issue led me to the solution: https://github.com/protocolbuffers/protobuf/issues/5482
The previous dev was not encoding data in base64, and that was causing deserialize issues in JavaScript.
I have a problem with jwtHelper.
After coding the data, I want to decode using:
myServices.service('checkToken', function( store, jwtHelper){
this.payload = function(){
var token = store.get ('token');
token = jwtHelper.decodeToken(token);
return token;
}
});
However, the console receives such an error:
TypeError: Cannot read property 'split' of undefined
at Object.decodeToken (angular-jwt.js:233)
at Object.payload (services.js:11)
Line 11: token = jwtHelper.decodeToken(token);
Are you sure the store is returning the token? Also I see a space between get and the paranthesis.
Does any one know why i get an illegal invocation error with this code? I think it is because I am trying to inject a profile image into the object that im getting - in the line addedCard.image = userInfo.image; but I dont know how to fix it. And because its part of a firebase listener its a continuous loop of errors and they keep adding up. This is the code that I have:
My service:
service.cardAdded = function(cb){
// if(target === "all"){
if($rootScope.validID){
prayersRef.orderByChild("group").equalTo($localStorage.seedUser.id).on('child_added', function(snapshot){
var val = snapshot.val();
cb.call(this, {
to: val.to,
from: val.from,
date: val.date,
assigned: val.assigned,
group: val.group,
passage: val.passage,
id: snapshot.key()
});
});
}
};
My controller:
myService.cardAdded(function(addedCard){
$scope.card.push(addedCard);
ProfileService.retrieveName(addedCard.assigned,function(userInfo) {
if (userInfo.image) {
addedCard.image = userInfo.image; //I think that this is causing the error
};
});
});
this is the error:
TypeError: Illegal invocation
at isArrayLike (angular.js:266)
at forEach (angular.js:322)
at copy (angular.js:832)
at copy (angular.js:798)
at copy (angular.js:838)
at copy (angular.js:798)
at copy (angular.js:820)
at copy (angular.js:790)
at copy (angular.js:838)
at copy (angular.js:798)
(anonymous function) # angular.js:11706
(anonymous function) # angular.js:8619
(anonymous function) # angular.js:16417
completeOutstandingRequest # angular.js:4940
(anonymous function) # angular.js:5328
Any help would be appreciated. Thank you
This guidance from the AngularJS might be useful:
Lower-level DOM manipulation from your JS code ... is no-no with AngularJS
and
If you stick to manipulating data model angular.copy will work just fine.
https://github.com/angular/angular.js/issues/8353
Your code is calling angular.copy implicitly (you can see that in your Chrome error) so make sure you are only copying you data model, not whole DOM elements.
Have you tried assigning only the elements that you need from the userInfo.image to addedCard.image, instead of copying the whole object, like this?
addCard.image = new Card(userInfo.image);
function AddCard(userImage) {
var obj = {
// Assign the needed attributes
};
return obj;
}
i have declared an array in a constructor and im trying to push a value in the function declared.but when i try to access that in another function there is no scope. PFB my code
function a() {
console.log("Constructor");
this.methods = ["getStatus","getLocation"];
}
a.prototype.invoke(){
this.methods.push("functionName");
console.log("this.methods new 123------------->",JSON.stringify(this.methods))
}
a.prototype.methods(){
console.log("JSON.stringify(this.methods) ---------------------->",JSON.stringify(this.methods))
}
below is the output that is getting printed
this.methods new 123 ----------------------> ["getStatus","getLocation","functionName"]
JSON.stringify(this.methods) ----------------------> ["getStatus","getLocation"]
There is no scope in function methods
I want the array as below
JSON.stringify(this.methods) ----------------------> ["getStatus","getLocation","functionName"]
I'm stuck kindly help