title: Call REST API and store its response in Context API
body: <p>I have a requirement in my react application to store API driven data in Context API. Class functions are not there only functional components we are using.</p>
  
  <p>I have tried to use await with fetch call but no success</p>
  
  <pre><code>const App = props =&gt; {
    const { initState } = props
    return (
      &lt;AppContextProvider  initState={initState}&gt;
        &lt;HoldingDetailsContainer initState={initState} /&gt;
      &lt;/AppContextProvider&gt;
    )
  }
  
  const AppContextProvider = (props) =&gt; { 
      const { resources } = useGetResourceApi();
  
  
      const context = {
          resources 
      };
      return (
          &lt;AppContext.Provider value={context}&gt;
              {props.children}
          &lt;/AppContext.Provider&gt;
      )
  }
  </code></pre>
  
  <p>If i use await in front of <code>useGetResourceApi</code> then it throws error "Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead."</p>
  
  <p>Is it possible to store API driven data in context API</p>