Skip to content

Commit e764702

Browse files
solved the cachepolicy issue
1 parent 5bb781b commit e764702

File tree

2 files changed

+3
-133
lines changed

2 files changed

+3
-133
lines changed

src/core/lib/utils.js

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,9 @@ export function sendRequest(queryObject) {
312312
});
313313
}
314314
};
315-
console.log("cachePolicy", cachePolicy)
316315
switch (cachePolicy) {
317316
case 1:
318317
return new Promise(function(resolve, reject) {
319-
console.log("self.prvider>>>>>", self.provider)
320318
if (self.provider !== null) {
321319
self.provider.get(hashQuery, function(err, _data) {
322320
try {
@@ -349,19 +347,17 @@ console.log("cachePolicy", cachePolicy)
349347

350348
var promise = new Promise(function(resolve, reject) {
351349
if (self.provider !== null) {
352-
console.log("inside the catche")
353350
self.provider.get(hashQuery, function(err, _data) {
354351
try {
355352
if (err || !_data) {
356-
return reject(err);
353+
reject(err);
357354
//reject(Error("It broke"));
358355
} else {
359-
console.log("inside else part")
360356
if (!tojson) _data = resultWrapper(_data);
361-
return resolve(spreadResult(_data));
357+
resolve(spreadResult(_data));
362358
}
363359
} catch (e) {
364-
return reject(e);
360+
reject(e);
365361
}
366362
});
367363
}
@@ -377,76 +373,5 @@ console.log("cachePolicy", cachePolicy)
377373
});
378374
console.error(error)
379375
})
380-
381-
// return {
382-
// cache: (function() {
383-
// console.log("inside cache")
384-
// return new Promise(function(resolve, reject) {
385-
// self.provider.get(hashQuery, function(err, _data) {
386-
// console.log("datatatat", _data)
387-
// try {
388-
// if (err) {
389-
// reject(err);
390-
// } else {
391-
// console.log("else part")
392-
// if (!tojson) _data = resultWrapper(_data);
393-
// console.log("spreddatat", _data)
394-
// resolve(spreadResult(_data));
395-
// }
396-
// } catch (e) {
397-
// reject(e);
398-
// }
399-
// });
400-
// });
401-
// }()),
402-
// network: (function() {
403-
// console.log("inside netwrk")
404-
// return new Promise(function(resolve, reject) {
405-
// callback(true, resolve, reject);
406-
// });
407-
// }()),
408-
// both: function(_callback_) {
409-
// console.log("inside both")
410-
// if (self.provider !== null) {
411-
// self.provider.get(hashQuery, function(err, entries) {
412-
// if (!tojson) entries = resultWrapper(entries);
413-
// _callback_(err, spreadResult(entries))
414-
// });
415-
// }
416-
// Request(queryObject.requestParams)
417-
// .then(function(data) {
418-
// console.log("datattatat>>>>>>>", data)
419-
// try {
420-
// self.entry_uid = self.tojson = self.queryCachePolicy = undefined;
421-
// let entries = {},
422-
// error = null;
423-
// if (queryObject.singleEntry) {
424-
// queryObject.singleEntry = false;
425-
// if (data.schema) entries.schema = data.schema;
426-
// if (data.content_type) {
427-
// entries.content_type = data.content_type;
428-
// delete entries.schema
429-
// }
430-
// if (data.entries && data.entries.length) {
431-
// entries.entry = data.entries[0];
432-
// } else if (data.assets && data.assets.length) {
433-
// entries.assets = data.assets[0];
434-
// } else {
435-
// error = { error_code: 141, error_message: 'The requested entry doesn\'t exist.' };
436-
// }
437-
// } else {
438-
// entries = data;
439-
// }
440-
// if (!tojson) entries = resultWrapper(entries);
441-
// _callback_(error, spreadResult(entries));
442-
// } catch (e) {
443-
// _callback_(e);
444-
// }
445-
// }.bind(self))
446-
// .catch(function(error) {
447-
// _callback_(error);
448-
// });
449-
// }
450-
// };
451376
}
452377
};

src/core/stack.js

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -288,61 +288,6 @@ export default class Stack {
288288
}
289289

290290

291-
/**
292-
* @method getAllContentType
293-
* @description getAllContentType get all the ContentTypes whose last activity updated.
294-
* @example Stack.getAllContentType()
295-
* @example
296-
* let data = Stack.getAllContentType().toJSON().fetch()
297-
* data
298-
* .then(function(result) {
299-
* // 'result' is list of contentTypes whose last activity updated.
300-
* }, function(error) {
301-
* // error function
302-
* })
303-
* @returns {Stack}
304-
* @ignore
305-
*/
306-
getAllContentTypes() {
307-
let query = {
308-
method: 'POST',
309-
headers: this.headers,
310-
url: this.config.protocol + "://" + this.config.host + ':' + this.config.port + '/' + this.config.version + this.config.urls.content_types,
311-
body: {
312-
_method: 'GET'
313-
}
314-
};
315-
return Request(query);
316-
}
317-
318-
/**
319-
* @method getContentType
320-
* @description getContentType get all the ContentTypes whose last activity updated.
321-
* @example Stack.getContentType()
322-
* @example
323-
* let data = Stack.getContentType().toJSON().fetch()
324-
* data
325-
* .then(function(result) {
326-
* // 'result' is list of contentTypes whose last activity updated.
327-
* }, function(error) {
328-
* // error function
329-
* })
330-
* @returns {Stack}
331-
* @ignore
332-
*/
333-
getContentType(content_type_uid) {
334-
let query = {
335-
method: 'POST',
336-
headers: this.headers,
337-
url: this.config.protocol + "://" + this.config.host + ':' + this.config.port + '/' + this.config.version + this.config.urls.content_types + content_type_uid,
338-
body: {
339-
_method: 'GET',
340-
environment: this.environment
341-
}
342-
};
343-
return Request(query);
344-
}
345-
346291
/**
347292
* @method sync
348293
* @description Syncs your Contentstack data with your app and ensures that the data is always up-to-date by providing delta updates

0 commit comments

Comments
 (0)