I did write a Javascript code to upload a file via API:
function submitForm(bucket, accessToken) {
console.log("Fetching the file...");
var input = document.getElementsByTagName('input')[0];
var name = input.files[0].name;
var uploadUrl = 'https://www.googleapis.com/upload/storage/v1/b/'+ bucket +'/o?uploadType=media&access_token=' + accessToken +'&name=' + name;
fetch(uploadUrl, {
method: 'POST',
body: input.files[0]
}).then(function(res) {
console.log('Something did happen!'); // <<----- Message never displayed!
});
}
However, I am not able to get the response body from the post request. The upload went well, but without a callback I cannot control the result in a deterministic way. How can I fix it, at least getting the HTTP Status Code?