22
33const ContentstackDemo = require ( './contentstack-demo.js' )
44
5- const Demo = new ContentstackDemo ( { 'api_key' : 'bltsomething123 ' , 'access_token' : 'bltsomething123 ' , 'environment' : 'development' } )
5+ const Demo = new ContentstackDemo ( { 'api_key' : '<api_key> ' , 'access_token' : '<Delivery_token> ' , 'environment' : '<Environment>' } )
66
7- //get all the entries
8- Demo
9- . getEntries ( 'source' )
10- . spread ( function ( result ) {
7+
8+ // Demo
9+ // .getEntries('source')
10+ // .then(function(result) {
11+ // // result object with entry
12+ // console.info("Result2 : ", result)
13+
14+ // //console.info("Result2 : ", JSON.stringify(result))
15+
16+ // })
17+ // .catch(function(err) {
18+ // // error of get entry
19+ // console.error("Fetch Error :", err)
20+ // })
21+
22+
23+
24+ //get all the entries
25+ Demo . getSyncApi ( { "init" : true , "type" : "asset_published" } )
26+ . then ( function ( result ) {
1127 // result object with entries
1228 console . info ( "Result: " , result )
1329
1733 console . error ( "Find Error :" , err )
1834 } )
1935
20- // get single entry
21- Demo
22- . getEntry ( 'source' , 'bltsomething123' )
23- . then ( function ( result ) {
24- // result object with entry
25- console . info ( "Result2 : " , JSON . stringify ( result ) )
26- } )
27- . catch ( function ( err ) {
28- // error of get entry
29- console . error ( "Fetch Error :" , err )
30- } )
3136
32- // get single asset
33- Demo
34- . getAsset ( 'bltsomething123' )
35- . then ( function ( result ) {
36- // result object with entry
37- console . info ( "Result2 : " , result )
38- } )
39- . catch ( function ( err ) {
40- // error of get entry
41- console . error ( "Fetch Error :" , err )
42- } )
4337
44- // get all assets
45- Demo
46- . getAssets ( )
47- . spread ( function ( result ) {
48- // result object with entry
49- console . info ( "Result2 : " , result )
50- for ( let i = 0 , _i = result . length ; i < _i ; i ++ ) {
51- // Image optimization
52- const imgUrl = Demo . Stack . imageTransform ( result [ i ] [ 'url' ] , {
53- quality : 50 ,
54- format : 'jpg'
55- } )
56- console . log ( "Image URL : " , imgUrl )
57- }
58- } )
59- . catch ( function ( err ) {
60- // error of get entry
61- console . error ( "getAssets Fetch Error :" , err )
62- } )
38+ // // get single asset
39+ // Demo
40+ // .getAsset('bltsomething123')
41+ // .then(function(result) {
42+ // // result object with entry
43+ // console.info("Result2 : ", result)
44+ // })
45+ // .catch(function(err) {
46+ // // error of get entry
47+ // console.error("Fetch Error :", err)
48+ // })
49+
50+
51+
52+ // // get all assets
53+ // Demo
54+ // .getAssets()
55+ // .spread(function(result) {
56+ // // result object with entry
57+ // console.info("Result2 : ", result)
58+ // for (let i = 0, _i = result.length; i < _i; i++) {
59+ // // Image optimization
60+ // const imgUrl = Demo.Stack.imageTransform(result[i]['url'], {
61+ // quality: 50,
62+ // format: 'jpg'
63+ // })
64+ // console.log("Image URL : ", imgUrl)
65+ // }
66+ // })
67+ // .catch(function(err) {
68+ // // error of get entry
69+ // console.error("getAssets Fetch Error :", err)
70+ // })
71+
72+
73+
74+ // get all assets
75+ // Demo
76+ // .getSyncApi({"sync_token": "blt123something"})
77+ // .then(function(result) {
78+
79+ // console.log("result", JSON.stringify(result))
80+
81+ // })
82+ // .catch(function(err) {
83+ // // error of get entry
84+ // console.error("getSync Fetch Error :", err)
85+ // })
86+
87+
88+
89+
90+
0 commit comments