According to this post Show that if $f$ is analytic in a domain $D$ and $|f(z)|$ is constant in $D$, then the function $f(z)$ is constant in $D$ We have,
If $f$ is analytic in a domain $D$ and $|f(z)|$ is constant in $D$ then the function $f(z)$ is constant in $D$.
But, If I consider the function $f(z) =e^{iz}$ then clearly $f$ is analytic on any domain $D\subseteq\mathbb{C}$. Moreover, $|f(z) |=1$ for all $z\in D$ But, $f(z) =e^{iz}$ is Not constant in $D$.
I think, I made some mistake. But I am not getting where! Please help me.
Correct.
No. $|f(z)|=1$ if and only if $z\in\mathbb{R}$. But for example $f(i)=e^{-1}$ and so $|f(i)|\neq 1$.
When we are dealing with complex analysis, the term "domain" almost always means at least open subset of $\mathbb{C}$. And therefore $D\subseteq \mathbb{R}$ is impossible, since $\mathbb{R}$ has empty interior in $\mathbb{C}$.
And this implies that $|f(z)|=1$ for all $z\in D$ is also impossible.