Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

store.js 2.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  1. var Promise = require('bluebird');
  2. var ReviewsOptions = [
  3. '“Very stylish, great stay, great staff”',
  4. '“good hotel awful meals”',
  5. '“Need more attention to little things”',
  6. '“Lovely small hotel ideally situated to explore the area.”',
  7. '“Positive surprise”',
  8. '“Beautiful suite and resort”'];
  9. module.exports = {
  10. searchHotels: function (destination) {
  11. return new Promise(function (resolve) {
  12. // Filling the hotels results manually just for demo purposes
  13. var hotels = [];
  14. for (var i = 1; i <= 5; i++) {
  15. hotels.push({
  16. name: destination + ' Hotel ' + i,
  17. location: destination,
  18. rating: Math.ceil(Math.random() * 5),
  19. numberOfReviews: Math.floor(Math.random() * 5000) + 1,
  20. priceStarting: Math.floor(Math.random() * 450) + 80,
  21. image: 'https://placeholdit.imgix.net/~text?txtsize=35&txt=Hotel+' + i + '&w=500&h=260'
  22. });
  23. }
  24. hotels.sort(function (a, b) { return a.priceStarting - b.priceStarting; });
  25. // complete promise with a timer to simulate async response
  26. setTimeout(function () { resolve(hotels); }, 1000);
  27. });
  28. },
  29. searchHotelReviews: function (hotelName) {
  30. return new Promise(function (resolve) {
  31. // Filling the review results manually just for demo purposes
  32. var reviews = [];
  33. for (var i = 0; i < 5; i++) {
  34. reviews.push({
  35. title: ReviewsOptions[Math.floor(Math.random() * ReviewsOptions.length)],
  36. text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris odio magna, sodales vel ligula sit amet, vulputate vehicula velit. Nulla quis consectetur neque, sed commodo metus.',
  37. image: 'https://upload.wikimedia.org/wikipedia/en/e/ee/Unknown-person.gif'
  38. });
  39. }
  40. // complete promise with a timer to simulate async response
  41. setTimeout(function () { resolve(reviews); }, 1000);
  42. });
  43. }
  44. };
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...