If so, you need to use Cross Domain to overcome this issue apply this code below in your app.js
JSOM Method
'use strict';
var hostweburl, appweburl;
var myList;
$(document).ready(function () {
appweburl = window.location.protocol + "//" + window.location.host + _spPageContextInfo.webServerRelativeUrl;
hostweburl = _spPageContextInfo.siteAbsoluteUrl;
var scriptbase = hostweburl + "/_layouts/15/";
$.getScript(scriptbase + "SP.Runtime.js",
function () {
$.getScript(scriptbase + "SP.js", retrieveListItems);
}
);
});
function retrieveListItems() {
var context = new SP.ClientContext(appweburl);
var appContextSite = new SP.AppContextSite(context, hostweburl);
myList = appContextSite.get_web().get_lists().getByTitle("yourListTitle");
context.load(myList);
context.executeQueryAsync(onGetWebSuccess, onGetWebFail);
//the remaining code is omitted for clarity
}
function onGetWebSuccess() {
alert("calling" + myList.get_title());
}
function onGetWebFail(sender, args) {
alert('Failed to get lists. Error:' + args.get_message());
}
Rest API Call
var executor;
executor = new SP.RequestExecutor(appweburl);
executor.executeAsync( {
url: appweburl + "/_api/SP.AppContextSite(@target)/web/Folders@target='" + hostweburl + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: getSuccessHandler,
error: getErrorHandler
}
For more details about Cross Domain follow this link