If you want to go the road with the props Derek is mentioning you could do something like this:
var clientContext = new SP.ClientContext(siteRelUrl);
var file = clientContext.get_web().getFileByServerRelativeUrl( siteRelUrl + "/SitePages/Home.aspx");
var limitedWebPartManager = file.getLimitedWebPartManager(SP.WebParts.PersonalizationScope.shared);
var collWebPart = limitedWebPartManager.get_webParts();
clientContext.load(collWebPart, 'Include(WebPart.Properties, WebPart.Title)');
clientContext.executeQueryAsync(() => {
if (collWebPart.get_count()) {
var webPartEnumerator = collWebPart.getEnumerator();
while (webPartEnumerator.moveNext()) {
var webPartDef = webPartEnumerator.get_current();
var webPart = webPartDef.get_webPart();
console.log(webPart.get_title())
if(webPart.get_title() == "Todo") {
var webPartProperties = webPart.get_properties();
// Take a look the props here, QueryTemplate maybe
console.log( JSON.parse(webPartProperties.get_item("DataProviderJSON")) )
//webPartProperties.set_item("DataProviderJSON", newDataProviderJSONval);
//webPartDef.saveWebPartChanges();
}
}
clientContext.executeQueryAsync(function() {
// Success
}, (s,a) => { console.log(a.get_message()) });
}
}, (s,a) => { console.log(a.get_message()) });
I'm not sure of the props you'll need to change, never done it, only for other web parts.