当我将这个 link 输入到我的 importJSON 函数(下面的代码)时,它会在重定向到实际链接之前转到 https://www.google.com/url?q=https://www.walmart.com/grocery/v3/api/products/44391159?itemFields=all&storeId=4456&nutritionPrescriptive=true。这是(我相信)导致我收到此错误:
CmakeList.txt
有时,我会成功,所以我认为由于谷歌在重定向到实际链接之前首先执行此操作会导致问题,我该如何解决这个问题?这是我正在使用的代码:
SyntaxError: Unexpected token < in JSON at position 0 (line 222).
答案 0 :(得分:0)
我在最近的一个问题中看到过这样的用法:
let url ='something'
do{
UrlFetchApp.fetch(url, {'followRedirects': false, 'muteHttpExceptions': false});
let redirectUrl = response.getHeaders()['Location'];
if(redirectUrl) url = redirectUrl;
//You can potentially do something in here between redirects if you wish
}while(url)