Heroku logs mistake unexpected token same code as in the mooc - json

I made a mooc on udemy regarding chatbots. Unfortunately, I failed at the point where I wanted the chatbot to send me data via mail.
What does this log expression tells me? What might be the mistake here?
Where can I search for the mistake?

You forgot a ) at line 35, the simple syntaxt for a if is:
if (condition) {
// do something
} else {
// or anything else
}
You should learn about if statement, here an example : https://www.w3schools.com/js/js_if_else.asp
Basically, a SyntaxError shows to you the line where the error happened, here /app/app.js:35, so the error is in your file app.js at line :35.
Here more clarification: https://www.digitalocean.com/community/tutorials/understanding-syntax-and-code-structure-in-javascript
It's possible that you have an other error yet, but we only see the end of it in your screenshot..

Related

Python capturing "HTTP status code" exception messages

I am having problems error handling code when deleting a file from box.com using Box API. The code establishes a connection to Box.com via JSON.
client.file(file_id=99999999999).delete()
When I run the command, the Box APIs uses HTTP status codes to communicate if a request has been successfully processed or not. This is what I see in PyCharm:
Error output
How do I use this error response (the red text in the bottom of the screen to handle errors so I can do something like this:
try:
client.file(file_id=xxxxxxxxxx).delete()
except 404:
print('error 404 occurred')
except 405:
print('error 405 occurred')
Thanks
#xaleel
I have tried this:
config = JWTAuth.from_settings_file(JSONFile)
client = Client(config)
try:
client.file(file_id=99999999999).delete()
except BoxAPIException as e:
print(e.status)
The error returned is:
Traceback (most recent call last):
File "C:\Temp\Box\Test\Test.py", line 20, in
except BoxAPIException as e:
NameError: name 'BoxAPIException' is not defined. Did you mean: 'BaseException'?
I have also tried "BoxException". Is this case sensitive? where can I look to see the correct possible name to use? Sorry I am not a programmer and really new to Python. I just set myself this challenge to learn!

Wakanda server start JSON error unexpected EOF

WAK 1.1.3 - during solution load, get a backend error:
[Backend] Error
[Backend] SyntaxError: JSON Parse error: Unexpected EOF
But it is not clear what file has this issue. How to most efficiently isolate this? I see nothing in the logs. The application has been running stably. I assume this is in a method, but am not finding it after a thorough search.
Thanks for guidance.
Kirk
Unexpected EOF error could be as small as forgetting to close function body with a right curly bracket.
I recommend first checking all the code on the backend you have modified since the last successful restart.
Secondly, since this occurs during solution load, the error is likely in bootstrap code including login listener. Or in model.js. You could try comment out all code in bootstrap.js or model.js see if the solution can load.

Issue with Google-API-PHP Client, getting error when running the quick start script

I am facing an issue with quickstart php script here: https://developers.google.com/drive/v2/web/quickstart/php
When I run the script first time, it executes perfectly and the access token is stored in a file called: drive-php-quickstart.json
When I run the script second time, it gives me the error:
Error start:
Notice: Undefined index: expires_in in \google-api-php-client\src\Google\Client.php on line 485
Fatal error: Uncaught exception 'LogicException' with message 'refresh token must be passed in or set as part of setAccessToken' in
Error end:
My assumption is that access token been saved in the file is not in the right format.
Current format:
ya29.CODE-oN_Bearer36001/_ANOTHER-CODE-ANOTHER_ANOTHER_CODE
As you can see, it does not contain the variable "expires_in"
Any suggestions where I am going wrong ? I am running the script as it is, with no modifications.
I've debugged it.... The person who wrote it made a mistake by not calling json_encode before writing the auth result to the token.json file.
You can fix it by adding json_encode on line 45.
So...
file_put_contents($credentialsPath, $accessToken);
...should be:
file_put_contents($credentialsPath, json_encode($accessToken));
I've submitted feedback so hopefully it'll be fixed.
edit: same issue happens for the token refresh call in that same method
edit2: Here's my related comment in a Github discussion and an answer from Google: https://github.com/google/google-api-php-client/issues/263#issuecomment-186557360
I suggested something along the following lines:
if ($client->isAccessTokenExpired()) {
$refreshToken = $client->getRefreshToken();
$client->refreshToken($refreshToken);
$newAccessToken = $client->getAccessToken();
$newAccessToken['refresh_token'] = $refreshToken;
file_put_contents($credentialsPath, json_encode($newAccessToken));
}
Instead of:
// Refresh the token if it's expired.
if ($client->isAccessTokenExpired()) {
$client->refreshToken($client->getRefreshToken());
file_put_contents($credentialsPath, $client->getAccessToken());
}
Google has updated their PHP Quickstart, with an improved method to handle this:
// Exchange authorization code for an access token.
$accessToken = $client->fetchAccessTokenWithAuthCode($authCode);
$client->setAccessToken($accessToken);
// Refresh the token if it's expired.
if ($client->isAccessTokenExpired()) {
$client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
file_put_contents($credentialsPath, json_encode($client->getAccessToken()));
}

Newbie: Getting basic app script to work, encountered AppKey error

I am following the instructions here to get a basic appscript to work. When I load the given page ("quickstart.html"), it does properly prompt me to "authorize" the connection. After authorizing, it redirects me to an error page with the error:
[ORIGINAL ERROR] generic::not_found: com.google.apps.docs.error.DocumentNotFoundException: Invalid or missing required AppKey
The invalid/missing AppKey suggests that this is a basic configuration issue. Other than the html file itself, where else should I be looking to find how/where the "AppKey" is managed?
Aha, figured it out. I had neglected to fill in the ENTER_YOUR_SCRIPT_ID_HERE variable. That was easy! :)

Unexpected token in CSS when editing it in vnext

When I try to write some css through Vnext or Webmatrix v2 beta I got error that unxpected token :
sometime I change something and got error that unexpected error ;
When I try this
body
{
background-color :Aqua;
}
I wonder all browser (moz,chrome) give me error that "Uncaught SyntaxError: Unexpected token :"
Later I save it from vs2010 but i still have error. Can someone tell me where I am doing wrong.
The error suggests that you're trying to load your CSS as if it were Javascript.
Maybe Vnext is expecting the : to be beside the background-color?
Try this
background-color: Aqua