json - Consuming JSONP in Google Apps Script -
I want to consume the following URL in my Google Apps Script: http: //a0.awsstatic Com / Pricing / 1 / emr / pricing-mapr.min.js
normal feedback = .getContentText () doesn 'by using UrlFetchApp.fetch (url) , It's just surrounded by JSON with callback () . Is there a way to consume JSONP with Google Apps Script?
Code:
function myFunction () {getEmrPricingData_ (); } / * * Get the EMR value * * Get / get functionEmRPCringData_ () {var emr_url = "http://a0.awsstatic.com/pricing/1/emr/pricing-mapr.min.js" var response = UrlFetchApp. Fetch (emr_url) .getContentText (); Logger.log (feedback); } " ) To execute the function of your JSONP response. For example, to handle JSONP responses on one of my projects, I have created this function:
function callback (data) {return data; }
and in my request function:
var result = eval (UrlFetchApp.fetch (url + uri, option) .getContentText ());
Comments
Post a Comment