title: Unable to consume REST API in SAPUI5
body: <p>I am trying to develop a weather app which consumes 3rd party services (<a href="http://openweathermap.org/" rel="nofollow noreferrer">API link here</a> ) for which the code is given in this <a href="https://blogs.sap.com/2016/03/22/webide-how-to-consume-3-party-services-in-ui5-app/comment-page-1/#" rel="nofollow noreferrer">link</a>. When I run the app, it shows ther table with no data. It also shows as error in my View1.Controller file which I have provided below. </p>
  
  <p>View1.controller.js</p>
  
  <pre><code>        sap.ui.define([
          "sap/ui/core/mvc/Controller",
          "sap/ui/model/json/JSONModel"
      ], function(Controller) {
          "use strict";
  
          return Controller.extend("WeatherAPI.controller.View1", {
  
  
      onInit: function() {
                  this._loadForecast();
              },
  
              _formatDate: function(date) {
                  var d = new Date(date),
                      month = '' + (d.getMonth() + 1),
                      day = '' + d.getDate(),
                      year = d.getFullYear();
  
                  if (month.length &lt; 2) {
                      month = '0' + month;
                  }
                  if (day.length &lt; 2){
                      day = '0' + day;    
                  } 
                  return [year, month, day].join('-');
              },
  
              _mapResults: function(results) {
                  var oModel = this.getView().getModel();
                  oModel.setProperty("/city", results.city.name);
                  oModel.setProperty("/country", results.city.country);
  
                  var aForecastResults = [];
                  for (var i = 0; i &lt; results.list.length; i++) {
                      var oTemp = results.list[i].temp;
                      var date = this._formatDate(results.list[i].dt * 1000);
                      aForecastResults.push({
                          date: date,
                          temp: oTemp.day,
                          units: "Celsius",
                          humidity: results.list[i].humidity
                      });
                  }
  
                  oModel.setProperty("/items", aForecastResults);
              },
  
              _loadForecast: function() {
                  var oView = this.getView();
                  var oParams = {
                      q: "London",  // Get the weather in london
                      units: "metric", 
                      appid: "fa2a1fb5db6debe044492728ca66a8f8",  // replace with your API key
                      cnt: 16,  // get weather for the next 16 days
                      mode: "json"  // get it in JSON format 
                  };
                  var sUrl = "/OpenWeather/data/2.5/forecast/daily";
                  oView.setBusy(true);
  
                  var self = this;
  
                  $.get(sUrl, oParams)
                      .done(function(results) {
                          oView.setBusy(false);
                          self._mapResults(results);
                      })
                      .fail(function(err) {
                          oView.setBusy(false);
                          if (err !== undefined) {
                              var oErrorResponse = $.parseJSON(err.responseText); /*error : Uncaught SyntaxError: Unexpected token &lt; in JSON at position 0
  at JSON.parse (&lt;anonymous&gt;) */
                              sap.m.MessageToast.show(oErrorResponse.message, {
                                  duration: 6000
                              });
                          } else {
                              sap.m.MessageToast.show("Unknown error!");
                          }
                      });
              }
          });
      });
  </code></pre>
  
  <p>model.js</p>
  
  <pre><code>        sap.ui.define([
          "sap/ui/model/json/JSONModel",
          "sap/ui/Device"
      ], function(JSONModel, Device) {
          "use strict";
  
          return {
  
              createDeviceModel: function() {
                  var oModel = new JSONModel(Device);
                  oModel.setDefaultBindingMode("OneWay");
                  return oModel;
              },
  
              createAPIModel: function() {
                  var oModel = new JSONModel();
                  oModel.setData({
                      city: "",
                      country: "",
                      cols: [{
                          name: "Date"
                      }, {
                          name: "Day Temperature"
                      }, {
                          name: "Units"
                      },{
                          name: "humidity"
                      }],
                      items: []
                  });
                  return oModel;          
              }
  
  
          };
      });
  </code></pre>
  
  <p>neo-app.json</p>
  
  <pre><code> {
    "path": "/OpenWeather",
    "target": {
      "type": "destination",
      "name": "OpenWeather",
      "entryPath": "/"
    },
    "description": "Open weather API"}
  </code></pre>
  
  <p>Please help. Thanks.</p>