title: Accessing IEnumerable returned by a POST request on javascript side (web API)
body: <p>I know that by the title it's hard to understand but I will try to explain. I have a Database of Employees, an html page connected to a script and a controller in my web api application. So, when I click a button on my html page, the relative javascript script sends a post request on my controller. The controller accesses the database and returns an <strong>IEnumerable</strong> to my javascript file. The query that the controller does on the database is the following:</p>
  
  <pre><code>[HttpPost]
  public IEnumerable&lt;Employee&gt; Post([FromBody] string name)
  {
      IEnumerable&lt;Employee&gt; query = Enumerable.Empty&lt;Employee&gt;();
      if (!String.IsNullOrEmpty(name))
      {
          query = from e in _db.Employees
          where e.Name.Contains(name)
          select e;
      }
      return query;
  }
  </code></pre>
  
  <p>this information is passed to the script. My problem is that I don't manage to access the single objects returned from the query. I debugged the code and made sure that the query returns an Enumerable of objects containing the right information I asked. On my script, I tried to access the members as:</p>
  
  <pre><code>$.post("api/employees", { '': insertedText }, function (result) {
  console.log(result[0].name);
  });
  </code></pre>
  
  <p>so the call <strong>console.log(result[0].name);</strong> should print the name of the first employee returned, but instead it does not. Can you help me understanding how to access properly such information?</p>