Skip to content

Instantly share code, notes, and snippets.

@bbachi
Created March 11, 2023 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbachi/556118021282c0ec2d4468245a84c609 to your computer and use it in GitHub Desktop.
Save bbachi/556118021282c0ec2d4468245a84c609 to your computer and use it in GitHub Desktop.
Seq
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