In my project, I wanted to save the data separately from the templates and the main.js. For instance,
in my data.js:
define({ heading: "Some Heading", subHeading : "Subheading is cool" });
in my main.js,
require(['jquery', 'data'], function($, data){ console.log("data object is :" + data); );
This works, and I get the intended result on the console. Similarly, I wanted to make an api call and get json data to update the data.js data as shown below,
define(function(){ require(["http://some api url.com?apikey=apikey&callback=define"], function (someData) { return someData; } ); });
but I do not get json data on main.js from the API call, I get " data object: undefined ".
I am not sure how to get "someData" in the main.js.
Any help pointing to a possible fix is ββmuch appreciated. Thanks.
source share