aws-mobile-ionic-sample icon indicating copy to clipboard operation
aws-mobile-ionic-sample copied to clipboard

Runtime Error JSON.parse

Open chrisswhitneyy opened this issue 7 years ago • 8 comments

JSON.pars: unexpected character at line 1 column 2 of the JSON data

Stack AwsConfig.prototype.load@http://localhost:8100/build/main.js:201892:42 @http://localhost:8100/build/main.js:154480:151 webpack_require@http://localhost:8100/build/main.js:20:12 @http://localhost:8100/build/main.js:127053:70 webpack_require@http://localhost:8100/build/main.js:20:12 @http://localhost:8100/build/main.js:63:18 @http://localhost:8100/build/main.js:1:11

I believe the issue is coming for the aws-config.js file inside the aws_cloud_logic_custum. I can replicate the error inside the browser development console. However, since this file was generate I'm not exactly sure what the issue is.

chrisswhitneyy avatar Mar 20 '18 04:03 chrisswhitneyy

I am also facing same issue.

SyntaxError: Unexpected token o in JSON at position 1 at JSON.parse () at AwsConfig.load (http://localhost:8100/build/main.js:202068:47) at Object.QueryParams.parseUrl (http://localhost:8100/build/main.js:154652:221) at webpack_require (http://localhost:8100/build/main.js:20:30) at Object. (http://localhost:8100/build/main.js:127225:70) at webpack_require (http://localhost:8100/build/main.js:20:30) at Object.defineProperty.value (http://localhost:8100/build/main.js:63:18) at http://localhost:8100/build/main.js:66:10

I am stuck with this issue since few weeks. Looks like aws_cloud_logic_custom is not returning pure json and creating this issue. but i have no clue as main.js is a generated file and not sure how it works.

Ramesh21 avatar Apr 01 '18 18:04 Ramesh21

This is a handmade workaround. But it can be worthly used until official developer team upgrades the repository. Open the file client/src/assets/aws-config.js and search for aws_cloud_logic_custom (should be line 9). After this line add this:

aws_cloud_logic_custom = JSON.stringify(aws_cloud_logic_custom);

This solves the issue for me

SimoneMSR avatar Apr 09 '18 15:04 SimoneMSR

Could anyone solve this for me? Uncaught ReferenceError: aws_cloud_logic_custom is not defined at AwsConfig.load (main.js:202082) at Object.QueryParams.parseUrl (main.js:154652) at webpack_require (main.js:20) at Object. (main.js:127225) at webpack_require (main.js:20) at Object.defineProperty.value (main.js:63) at main.js:66

plau1129 avatar Apr 10 '18 16:04 plau1129

@plau1129 Have you added the aws-config.js file as mentioned in the point 3 of client setup?

SimoneMSR avatar Apr 10 '18 23:04 SimoneMSR

Yes I do.

plau1129 avatar Apr 11 '18 00:04 plau1129

@plau1129 do you have the <script src="assets/aws-config.js"></script> line in the head tag of your client/index.html ?

SimoneMSR avatar Apr 11 '18 08:04 SimoneMSR

I think so. I didn't change anything after cloning the example. It was successfully run for only one time and then showing errors.

plau1129 avatar Apr 11 '18 08:04 plau1129

Hi All,

@SimoneMSR solution fixed the problem for me and allows the app to run.

Thanks @SimoneMSR !!

Lee

LeeCheetham avatar Jun 18 '18 13:06 LeeCheetham