Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

profile.service.js 619B

12345678910111213141516171819202122
  1. import { db } from '../utils/db'
  2. import { Profile } from '../entities/profile'
  3. /**
  4. * Get a single Profile from the database and
  5. * create a class from the data and
  6. * validate the incoming
  7. * @param {number} userId
  8. */
  9. const fetchProfilesByUserId = async userId => {
  10. const profilesForUserId = await db.get(`/user/${userId}/profiles`)
  11. const profileInstances = []
  12. profilesForUserId.map(profileData => {
  13. const profile = new Profile(profileData)
  14. if(profile.isValid()) {
  15. profileInstances.push(profile)
  16. }
  17. })
  18. return profileInstances
  19. }
  20. export { fetchProfilesByUserId }