title: Returning multiple values from WebApi (post) to AngularJs
body: <p>I am using .net core C#, WebApi &amp; AngularJs.</p>
  
  <p>For saving data my Angularjs code makes a $http call to my WebApi. I can return single data from my api fine but not sure whats the best method to return multiple values here. I can make it comma separated and then return as well, but wanted to know if there is a better approach to this.</p>
  
  <p>So basically when the API saves data to my db, I want to return a variable, boolean  value if the save was successful and an exception message in case the save was not successfully. Below is my code.</p>
  
  <p>AngularJs Code:</p>
  
  <pre><code>service.saveData(data).then(function (res) {                          
      //get someDataToReturn, dataSaved &amp; exception raised if any from db save here.
      }, function (err) {
  });
  </code></pre>
  
  <p>WebApi Code:</p>
  
  <pre><code>[HttpPost("data/save")]
  public async Task&lt;IActionResult&gt; SaveData([FromBody] List&lt;UserData&gt; data)
  {
      bool dataSaved = true;
      string someDataToReturn = string.Empty;
      //do some processing and updating someDataToReturn here         
  
      //Saving data to DB
      dataSaved = SaveData(data);                
  
      //I want to return someDataToReturn, dataSaved(true or false) and exception raised from SaveData if any 
      return Ok(someDataToReturn);
  }
  
  //DB Call to save data
  public bool SaveData(List&lt;UserData&gt; data)
  {           
      try
      {
          foreach (var set in data)
          {
              //creating query etc
  
              _db.Execute(query);
          }                
  
          return true;
      }
      catch (SqlException ex)
      {
  
      }
      return false;
  }
  </code></pre>
  
  <p>Let me know the best approach for this.</p>