Skip to content

Instantly share code, notes, and snippets.

@jeffreyvr
Last active December 10, 2019 08:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreyvr/fdbd207ba3d9eaf54d7f00fa9d0fc423 to your computer and use it in GitHub Desktop.
Save jeffreyvr/fdbd207ba3d9eaf54d7f00fa9d0fc423 to your computer and use it in GitHub Desktop.
Framework7 populate template from rest api
routes = [
{
path: '/items/',
async: function (routeTo, routeFrom, resolve, reject) {
app.preloader.show();
app.request({
beforeSend: function ( xhr ) {
xhr.setRequestHeader( 'authorization', localStorage.getItem('baseAuthentication') );
},
url: apiurl + '/posts/',
dataType: 'json',
method: "GET",
crossDomain: true,
success: function(response) {
resolve(
{
componentUrl: './pages/items.html',
},
{
context: {
items: response,
},
}
);
app.preloader.hide();
}
});
}
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment