I am using an api to retrieve a .png file. When I try to create a URL for it so that I can display it in my HTML, the call fails with the following error:
userCodeAppPanel:94 Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.
I am calling my api with this code (using Google Apps Script):
function retrieveAdmiraltyTideGraph(tideStationName, dateFrom, numDays){
//get tide station code from tide station name passed from user input
let tideStationCode = getTideStationCode(tideStationName)
var url = _admiraltyURL + "Stations/" + tideStationCode + "/TidalHeightGraph?dateTime=" + dateFrom + "&duration=" + numDays;
url = url + "&width=500&height=200"
var response = UrlFetchApp.fetch(url, _admiraltyRequestHeader);
var responseCode = response.getResponseCode()
var blob = response.getBlob()
Logger.log("graph response" + responseCode)
Logger.log(blob.getContentType())
return blob
}
The api call is successful as the logger shows a correct return code, the check on the content type of the blob shows it to be "image/png" as expected.
I call the api function from Java Script using:
google.script.run.withSuccessHandler(showGraph).withFailureHandler(onFailure).retrieveAdmiraltyTideGraph(selectedStation, dateFrom, numDays);
and the function call to display the retrieved image is:
function showGraph(blob){
var url = window.URL.createObjectURL(blob);
document.getElementById("graph").src = url
}
This is failing when I attempt to get the url.
I'm quite new to JS and Google Apps Script so i may be getting something simple wrong, but I have very similar functions which pass and process arrays between an api handler, server code and client code.
Any suggestions?
Thanks