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 1.0 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
  1. var Promise = require('bluebird');
  2. module.exports = {
  3. searchHotels: function (destination, checkInDate, checkOutDate) {
  4. return new Promise(function (resolve) {
  5. // Filling the hotels results manually just for demo purposes
  6. var hotels = [];
  7. for (var i = 1; i <= 5; i++) {
  8. hotels.push({
  9. name: destination + ' Hotel ' + i,
  10. location: destination,
  11. rating: Math.ceil(Math.random() * 5),
  12. numberOfReviews: Math.floor(Math.random() * 5000) + 1,
  13. priceStarting: Math.floor(Math.random() * 450) + 80,
  14. image: 'https://placeholdit.imgix.net/~text?txtsize=35&txt=Hotel+' + i + '&w=500&h=260'
  15. });
  16. }
  17. hotels.sort(function (a, b) { return a.priceStarting - b.priceStarting; });
  18. // complete promise with a timer to simulate async response
  19. setTimeout(function () { resolve(hotels); }, 1000);
  20. });
  21. }
  22. };
Tip!

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

Comments

Loading...