我正在尝试在我的反应应用中使用google drive api。
这是我的代码,当调用load
函数时,它返回404响应。
const google = require('gapi-client');
console.log('googleClient ', google);
let start = () => {
let settings = {
apiKey : 'PRIVATE API KEY'
, discoveryDocs: ['https://www.googleapis.com/discovery/v1/apis/drive/v3/rest']
, clientId : 'PRIVATE CLIENT ID'
, scopes : 'https://www.googleapis.com/auth/drive.metadata'
};
google.client.init(settings).then(() => {
console.log('request initialize finished :: ', arguments);
}, (err) => {
if(err) console.error('An error occurs while request gapi initialize :: ', err);
})
}
google.load('client', start);
function googlePhotoClient () {
}
let GooglePhotoClient = new googlePhotoClient();
module.exports = GooglePhotoClient;
这是浏览器控制台中的消息。
GET https://apis.google.com//scs/apps-static//js/k=oz.gapi.en.WcpMzqgmJZU.O/m=debug_error/rt=j/sv=1/d=1/ed=1/am=AQ/rs=AGLTcCNsTS1p4dx0iMhlrwEpiaXw4iMjOg/cb=gapi.loaded_0 404()localhost /:1拒绝执行脚本 'https://apis.google.com//scs/apps-static//js/k=oz.gapi.en.WcpMzqgmJZU.O/m=debug_error/rt=j/sv=1/d=1/ed=1/am=AQ/rs=AGLTcCNsTS1p4dx0iMhlrwEpiaXw4iMjOg/cb=gapi.loaded_0' 因为它的MIME类型('text / html')不可执行,而且是严格的MIME 启用了类型检查。
我认为第二行是如此真实,因为第一次返回是HTML 404消息。但我不知道为什么第一个ajax调用返回404
消息。
我有什么遗漏的吗?
由于