fix(usePhoneNumber): working hook

This commit is contained in:
chip committed 2020-10-20 01:20:08 +02:00
1 parent d70558c7e1
commit 86f5741618
1 file changed
+8 -3
+8 -3
View File
@@ -1,7 +1,12 @@
import { pool } from './db';
export const usePhoneNumber = async (identifier: string) => {
interface IPhoneNumber {
phone_number: string;
}
export async function usePhoneNumber(identifier: string): Promise<string> {
const query = "SELECT phone_number FROM users WHERE identifier = ?"
const phoneNumber = await pool.query(query, [identifier]);
return phoneNumber;
const [results] = await pool.query(query, [identifier]);
const phoneNumber = <IPhoneNumber[]>results;
return phoneNumber[0].phone_number;
}