Created
March 11, 2023 18:35
-
-
Save bbachi/556118021282c0ec2d4468245a84c609 to your computer and use it in GitHub Desktop.
Seq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios'); | |
export class UserService { | |
public async getUsers() { | |
return await axios.get('/api/users'); | |
} | |
public async getContacts() { | |
return await axios.get('/api/contacts'); | |
} | |
public async getAddresses() { | |
return await axios.get('/api/addresses'); | |
} | |
public async getUserInfo() { | |
try{ | |
const users = await this.getUsers(); | |
const contacts = await this.getContacts(); | |
const addresses = await this.getAddresses(); | |
const result: any = []; | |
users.data.map((user: any) => { | |
result.push({ | |
...user, | |
...contacts.data.find((contact: any) => contact.userId === user.userId), | |
...addresses.data.find((address: any) => address.userId === address.userId)}) | |
}); | |
return result; | |
}catch(error) { | |
return []; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment