You cannot change the file directly one submitted but you can use local javascript file to manually save json data (Like Down Below). Or you can use your Google’s APIs to fetch the the data from google drive files. Such that you can just update file in your google drive and the data will be updated. But Google APIs have certain limits for APIs calls for free use.
At first I assumed you want to save the file locally in the package itself . So I wrote the solution below:
So in order for you to update JSON Locally, you need use require(%code-folder-file-path%)
in javascript code. And In you data saving javascript file, use module.exports
function to send the data torequire(%code-folder-file-path%)
function when it is called from another file.
For Example:
Assume the hierarchy:
-asset
- code
|_ lib
| |_ DataCollection.js
|_ engine
|_ Search_Data_Algorithm.js
- action
- model
- resources
Note: Assume that the top hierarchy are the default Folder created when you create new capsule & by default the local path for Javascript Files starts at a root folder called “Code” which in this case contains “lib”, and “engine” as the sub-folders. So the initial top hierarchy folders such as “asset,code,action,model,resources” are the root folder for using the local file paths when calling for the files and folders contained within them.
- DataCollection.js
module.exports = JSON.parse(myJSON_data);
myJSON_data = “{•••}”;
- Search_Data_Algorithm.js
const Data = require(‘lib/DataCollection.js’);
/** since the root folder is “Code”,
* we don’t need to write:
* require(‘code/lib/DataCollection.js’)
*/
console.log(Data);
// this will output data in JSON file.
Also Note : if you want to use files from a folder one notch up in hierarchy use ../
in front of the path line and the file/folder name after it.