diff --git a/backend/src/services/ContactServices/GetContactService.ts b/backend/src/services/ContactServices/GetContactService.ts index 93b12e3..3865bc5 100644 --- a/backend/src/services/ContactServices/GetContactService.ts +++ b/backend/src/services/ContactServices/GetContactService.ts @@ -1,5 +1,6 @@ import AppError from "../../errors/AppError"; import Contact from "../../models/Contact"; +import CreateContactService from "./CreateContactService"; interface ExtraInfo { name: string; @@ -20,10 +21,18 @@ const GetContactService = async ({ name, number }: Request): Promise => }); if (!numberExists) { - throw new AppError("CONTACT_NOT_FIND"); + const contact = await CreateContactService({ + name, + number, + }) + + if (contact == null) + throw new AppError("CONTACT_NOT_FIND") + else + return contact } - return numberExists; + return numberExists }; export default GetContactService; \ No newline at end of file