Plugin: Difference between API and actual route
-
//Plugin's library.js
plugin.init = function(params, callback) {
var router = params.router,
hostMiddleware = params.middleware,
hostControllers = params.controllers;// We create two routes for every view. One API call, and the actual route itself. router.get('/map', hostMiddleware.buildHeader, controllers.renderMapPage); router.get('/api/map', controllers.renderMapPage); callback();
};
Ref: We create two routes for every view. One API call, and the actual route itself.
What exactly is the difference between these two routes/ What does API call mean? -
The API route doesn't render a template. It just outputs the JSON that is passed into
render
.You can test this by prepending
/api
on any route, you'll see JSON output.The purpose of this is for the AJAX loading of the next page.
Copyright © 2024 NodeBB | Contributors