How do I display value in input field [closed]

I have a reactjs input field that is read only. How do I change the placeholder and replace it automatically with whatever result I get from an api call?

Answer

You can do something like this:

import { useEffect, useState } from "react";

export default function App() {
  const [placeholder, setPlaceholder] = useState("defaultPlaceHolder");
  useEffect(() => {
   //here is a sample of api call
   setTimeout(() => {
      setPlaceholder("fromApi");
    }, 3000);

  }, []);
  return <input type="text" placeholder={placeholder} />;
}