SyntaxError: Unexpected token ':' on JavaScript file - Cookie Alert File - javascript

Has anyone experience the following JavaScript syntax error inside a JavaScript file for a cookie alert and have a solution to it? I am getting the error code below.
SyntaxError: Unexpected token ':' at https://*******.com/assets/web/assets/cookies-alert-plugin/cookies-alert-script.js:16:447 at new Promise (<anonymous>) at b (https://*******.com/assets/web/assets/cookies-alert-plugin/cookies-alert-script.js:16:167) at https://***********.com/assets/web/assets/cookies-alert-plugin/cookies-alert-script.js:17:142

Related

What is Unexpected token a in JSON at position 0?

I am getting an error that says SyntaxError: Unexpected token a in JSON at position 0
and I cannot find any information on what "a" means. I know that the JSON is not undefined.
Can anyone help me understand what is causing this error?
Here is the code block that is causing the error:
let db_creds = await getDBCredentials();
console.log(db_creds)
const pool = new Pool(JSON.parse(db_creds['SecretString']));
console.log(pool)
Unexpected Token < in JSON at Position 0. From time to time when working with JSON data, you might stumble into errors regarding JSON formatting. For instance, if you try to parse a malformed JSON with the JSON. ... json() method on the fetch object, it can result in a JavaScript exception being thrown.
What Is JSON and How to Handle an “Unexpected Token” Error
Well for me it was because the port was already in use and it must be sending HTML, you can try killing the port by running the below command in cmd(admin mode)
taskkill /F /IM node.exe

Postman regexp - SyntaxError: Invalid or unexpected token

I'm trying to write Postman test and validate personal identification number with regexp. I have validated regexp: \b((([0-2]{1}[0-9]{1}|[3]{1}[0-1]{1})[0-9]{1}[0-9]{1}[0-9]{1}[0-9]{1}(.|\n|\t|)[0-9]{5})|[3]{1}[2]{1}[0-9]{4}(.|\n|\t|)[0-9]{5})\b
Postman test script:
var req = JSON.parse(pm.request.body.raw);
pm.expect(req.personnumber).to.match( \b((([0-2]{1}[0-9]{1}|[3]{1}[0-1]{1})[0-9]{1}[0-9]{1}[0-9]{1}[0-9]{1}(.|\n|\t|)[0-9]{5})|[3]{1}[2]{1}[0-9]{4}(.|\n|\t|)[0-9]{5}\b), "wwww" );
});
Postman returns following error while trying to execute test script:
There was an error in evaluating the test script: SyntaxError: Invalid or unexpected token
This error SyntaxError: Invalid or unexpected token comes from that you forgot about / in the beginning and end of regexp:
pm.expect(req.personnumber).to.match( /\b((([0-2]{1}[0-9]{1}|[3]{1}[0-1]{1})[0-9]{1}[0-9]{1}[0-9]{1}[0-9]{1}(.|\n|\t|)[0-9]{5})|[3]{1}[2]{1}[0-9]{4}(.|\n|\t|)[0-9]{5}\b)/, "wwww" );

I am getting this error "Uncaught SyntaxError: Failed to construct 'WebSocket': The URL 'undefined' is invalid."

this.webSocket = new WebSocket(this.consumer.url);
when i ran my project i received this error on this line in file action_cable.self
please ask for any further code if needed.

"Fail Render" Javascript files and Css

I have a strange issue when trying to load some JS and CSS files.
I have an ASP.NET MVC Web Project and inside it I have Index.html and ask to load some script files. I believe it is important to mention that I rewrited the URL in Web.config so instead of showing me something like : localhost:2064/Index.html to show localhost:2064/ or localhost:2064/Index/.
I use the normal "call" for my scripts like:
<link href="/Content/bootstrap.min.css" rel="stylesheet" />
<link href="/Content/Site.css" rel="stylesheet" />
<script src="Scripts/jquery-1.10.2.min.js" ></script>
<script src="Scripts/bootstrap.min.js" ></script>
<script src="Scripts/bootstrap.js"></script>
<script src="Scripts/modernizr-2.6.2.js" ></script>
<script src="Scripts/Layout/menu.js" ></script>
But, in console I get some errors (Chrome Inspector Console):
Uncaught SyntaxError: Unexpected token < :2064/Scripts/jquery-1.10.2.min.js:1
Uncaught SyntaxError: Unexpected token < :2064/Scripts/bootstrap.min.js:1
Uncaught SyntaxError: Unexpected token < :2064/Scripts/bootstrap.js:1
Uncaught SyntaxError: Unexpected token < modernizr-2.6.2.js:1
Uncaught SyntaxError: Unexpected token < menu.js:1
Uncaught SyntaxError: Unexpected token < app.js:1
Uncaught SyntaxError: Unexpected token < indexController.js:1
Uncaught SyntaxError: Unexpected token < homeController.js:1
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.6/$injector/modulerr?p0=PBA&p1=Error%3A%20%…F1.2.6%2F%24injector%2Fnomod%3Fp0%3DPBA%0A%20%20%20%20at%20Error%20(native...<omitted>...4) MINERR_ASSET:22
When I inspected to see the content of those files I get the following info:
STATUS: 304 Not Modified
CONTENT: Same as my HTML file (not as expected).
Any help? Thanks in advance.
It looks to me that your rewrite logic is wrong.
If you analyze your errors you will see that each javascript file has a '<' character on the first line. That indicates to me that you are probably serving one of your html files instead of the actual javascript files.
Also make sure you are serving each file with a proper content type, ie 'text/javascript', 'text/html', etc.

Unexpected Token with Scripts using Jade and Express

I am new to Jade and I am having some problems with the Scripts.
In some of them, I get Unexpected Token errors... this is one example:
script
$(document).ready({
$('#answer').keyup(function(e) {
$('#preview').html($('#answer').val());
});
});
This should work fine in common HTML, but with Jade it says:
Uncaught SyntaxError: Unexpected token (
Do I have to use any special syntax with Jade?
Thanks.
In jade, script should be followed by .(dot)
like => script. (or) script(type="text/javascript").

Categories

Resources