gimenz1991

Igh

Mar 22nd, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. const axios = require('axios');
  2.  
  3. async function getItem(id) {
  4. const { data } = await axios.get('https://v2.aischedul.com/api/story/highlight/' + id);
  5. return data.highlightFeed
  6. }
  7.  
  8. async function highlight(username) {
  9. const { data } = await axios.get('https://v2.aischedul.com/api/story/' + username);
  10. const ids = data.highlight.map(async x => await getItem(x.id.split(':')[1]));
  11. const highlight = [];
  12. const asu = await Promise.all(ids)
  13. for (let i = 0; i < data.highlight.length; i++) {
  14. let title = data.highlight[i].title
  15. let time = data.highlight[i].timeSince
  16. let cover = data.highlight[i].url
  17. let list = asu[i]
  18. highlight.push({
  19. title,
  20. time,
  21. cover,
  22. list
  23. })
  24. }
  25.  
  26. return {
  27. profile: data.profile,
  28. highlight
  29. };
  30. }
  31.  
  32. highlight('adiraas.p')
  33. .then(res => {
  34. console.log(res.highlight[0]);
  35. })
  36. .catch(e => {
  37. console.log(e);
  38. });
Advertisement
Add Comment
Please, Sign In to add comment