MongoDB findAndModify SyntaxError: missing ) after argument list - javascript

db.RO_DECLINE_DATA.findAndModify("query":{"$or":[{"emailMessageID":345544985},{"textMessageID":345544985}]},"update":{"$set":{"emailMessageStatus":"FAILED","emailSentDate":null}});
db.INBOX_COLLECTION.aggregate("pipeline":[{"$match":{"dealerID":1224,"dealerDepartmentID":3994,"dealerAssociateID":{"$in":[68638,68891]}}},{"$group":{"_id":"$customerID"}}]);
I can't seem to figure out what is wrong with these queries?
Error
2021-07-14T01:28:06.106+0530 E QUERY [js] uncaught exception: SyntaxError: missing ) after argument list :
i don't think any ')' is missing

Related

"Uncaught SyntaxError: Unexpected token l in JSON at position 0", but still works, why?

First time using websockets with Go and getting a weird error that doesn't break the program, and still continue as if it was not a problem. The client is a ReactJS single page application.
JS Client:
const socket = new WebSocket("ws://localhost:5000/ws");
setConnection(socket);
socket.onmessage = (e) => {
const message = JSON.parse(e.data)
console.log("message:", message)
switch (message.Command) {
case "loginResult":
if (message.Result) {
console.log("login worked");
}else{
console.log("login did not work");
}
break;
}
}
Snippet of Go it is getting JSON from:
result := ws.LoginResult{
BaseMessage: ws.BaseMessage{
Command: "loginResult",
},
Result: false,
}
b, err := json.Marshal(result)
if err != nil {
fmt.Println(err)
return
}
if err = conn.WriteMessage(msgType, b); err != nil {
return
}
And the output:
in here
WebsocketProvider.tsx:20 message: {Command: 'loginResult', Result: false}
WebsocketProvider.tsx:27 login did not work
VM3502:1 Uncaught SyntaxError: Unexpected token l in JSON at position 0
at JSON.parse (<anonymous>)
at WebSocket.socket.onmessage (WebsocketProvider.tsx:19)
socket.onmessage # WebsocketProvider.tsx:19
Anyone have any idea why this is the case?
Solution was found:
It was to do with the migration of code and that a left over line was making a call that was ignored, hence where it made no difference to the execution. Nothing to do with the JSON format being difference since this was automatically generate by Go libraries.
the function you have written for onmessage will be run every time a valid websocket message has been received.
According to the debug log you have posted the bit that worked was when you did receive valid JSON from the server and the function ran to completion as evidenced by this line:
WebsocketProvider.tsx:27 login did not work
Mark the line number.
After this you get:
VM3502:1 Uncaught SyntaxError: Unexpected token l in JSON at position 0
at JSON.parse (<anonymous>)
at WebSocket.socket.onmessage (WebsocketProvider.tsx:19)
socket.onmessage # WebsocketProvider.tsx:19
mark the line number :19
This is the line with your JSON.parse.
My guess would be that this is a new invalid json message and it did indeed panic here and the rest of the function did not run - the bit that ran was a previous message with valid json.
As for why it failed - put in a console.log before your JSON.parse as suggested by #emptyhua to see what exactly you are receiving.

Location query in Overpass turbo

I have just learned about the overpass turbo service and its ability for querying data. I have tried the following query and it works fine:
[out:json][timeout:25];
(
node["highway"]({{bbox}});
);
out body;
But when I replace the bbox with a name of city which according to the wiki page of overpass it should be like below, the code gives an error. Would be glad to know what is the problem with the second code?
[out:json][timeout:25];
(
node["highway"]({{geocodeId: Vienna}});
);
out body;
error message:
An error occured during the execution of the overpass query! This is
what overpass API returned: Error: line 3: parse error: Unknown query
clause Error: line 3: parse error: ')' expected - 'node' found. Error:
line 4: parse error: Unknown type ")" Error: line 4: parse error: An
empty query is not allowed Error: line 4: parse error: Unknown type
";" Error: line 5: parse error: An empty query is not allowed
As you want to query nodes in a certain area, you need to use the following syntax for overpass turbo:
[out:json][timeout:25];
{{geocodeArea:Vienna}}->.searchArea;
node["highway"](area.searchArea);
out body;

Uncaught SyntaxError: Unexpected token < using CakePhP

I'm meeting a small problem with CakePhp... When I get an url like http://www.example.com/news/delete:5 , I always get this javascript error message, no matter what param I want to transfer through the url.
jquery-2.1.4.min.js:1 Uncaught SyntaxError: Unexpected token <
jquery-ui.min.js:1 Uncaught SyntaxError: Unexpected token <
In those files, at the first line.
Anyone can help me please? Thank you!

Javascript error; Uncaught SyntaxError: missing ) after argument list

I keep getting this error (Javascript error; Uncaught SyntaxError: missing ) after argument list) when trying to call a simple function. Everything works without calling it in a function but I need to do it multiple times.
function myFunction(ip, port, div) {
$.get('http://mcping.net/api/'+ ip + ":" + port, function(data){
console.log(data.online);
$(div).html(data.online);
});
}
myFunction(162.223.8.210, 25567, #factionsOnline)
You're missing a parentheses because you didn't quote your strings
myFunction('162.223.8.210', '25567', '#factionsOnline');

JSONP error: Uncaught SyntaxError: Unexpected token :

I am trying to get a json encoded object from here but I keep on receiving the following error "Uncaught Syntax Error: Unexpected token : ". I was wondering what is causing this error and what I could do to fix it. Thanks to anyone who can help. Here's my code.
<script>
function mycallback(answer){
var stuff = JSON.parse(answer);
alert(stuff);
console.log(stuff);
}
</script>
<script src="http://www.wcischeduleapp.com/app/get.php?callback=mycallback"></script>
The way JSONP works is that answer is already an object, not a JSON string any more.
So just console.log(answer); will work just fine.

Categories