简体   繁体   中英

Online Viewer Walkthrough Autodesk forge

I am following this tutorial for online viewer. https://forge.autodesk.com/developer/learn/viewer-app/overview

I am using Visual Studio Code as text editor. Every thing looks installed correctly. I am trying within 30 minutes of two legged authentication, even though this code is supposed to regenerate the token, after 30 minutes. Strange in debugging FORGE_CLIENT_ID is showing "undefined"

When I am running the code, first it is giving an error at line 107

c:\Users\Tahmina\Downloads\viewer-walkthrough-online.viewer-master\viewer-walkthrough-online.viewer-master\start.js:107
const bucketKey = FORGE_CLIENT_ID.toLowerCase + '_tutorial_bucket'; // Prefix with your ID so the bucket key is unique across all buckets on all other accounts
                                  ^

TypeError: Cannot read property 'toLowerCase' of undefined
    at Object.<anonymous> (c:\Users\Tahmina\Downloads\viewer-walkthrough-online.viewer-master\viewer-walkthrough-online.viewer-master\start.js:107:35)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Then I removed "toLowerCase" and wrote the line as

const bucketKey = FORGE_CLIENT_ID + '_tutorial_bucket';

This way it showed "Server listening on port 3000" and the page "authorize me!" in localhost. But when I pressed the button , authorization failed. That means, the bucket creation failed.

Please let me know, why the line number 107 was showing error.

Am I missing something ? Strange in debugging FORGE_CLIENT_ID is showing "undefined". I did run Cygwin terminal and generated token in right way and my app is open in forge account.

Looks like npm start is not working

log file is as below "

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@6.9.0
3 info using node@v10.16.3
4 verbose stack Error: missing script: start
4 verbose stack     at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:155:19)
4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:63:5
4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:115:5
4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:418:5
4 verbose stack     at checkBinReferences_ (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:373:45)
4 verbose stack     at final (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:416:3)
4 verbose stack     at then (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:160:5)
4 verbose stack     at ReadFileContext.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:332:20)
4 verbose stack     at ReadFileContext.callback (C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:90:16)
4 verbose stack     at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:237:13)
5 verbose cwd C:\Users\Tahmina\Downloads\viewer-walkthrough-online.viewer-master
6 verbose Windows_NT 10.0.17763
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
8 verbose node v10.16.3
9 verbose npm  v6.9.0
10 error missing script: start
11 verbose exit [ 1, true ]

I'd suggest to try the sample project here - see how it works and go from there. You can also follow the tutorial on LearnForge to start over from another perspective.

There are starter samples of different languages available here so you can pick one you know best - since Forge (with the exception of the Viewer library which is obviously entirely JavaScript) is 100% RESTful so it's basically language neutral.

If you'd like to stick with Node.JS you can follow the tutorial here (or any of the popular ones out there if you google them up) to wrap your head around the basics first.

I got the same problem, but after I declared the environment var with the commands

set FORGE_CLIENT_ID = yourforgeclientid
set FORGE_CLIENT_SECRET = yourforgeclientsecret

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM