gpt4 book ai didi

angularjs - 如何使用 Angularjs $Http POST 请求访问来自 Google Data Store 的数据?

转载 作者:行者123 更新时间:2023-12-04 15:53:23 24 4
gpt4 key购买 nike

我试过了,下面是我的代码,我不知道出了什么问题

$http({
method: 'POST',
headers:'{"gqlQuery": {"queryString": "select * from culture" }}',
url: 'https://datastore.googleapis.com/v1/projects/nammaooru-3630e:runQuery?fields=batch%2Cquery&key=[myapikey]'
}).then(function successCallback(response) {

alert("Success"+response);
// this callback will be called asynchronously
// when the response is available
}, function errorCallback(response) {
alert("Error"+response);
// called asynchronously if an error occurs
// or server returns response with an error status.
});
Angular 请求出错**

https://datastore.googleapis.com/v1/projects/nammaooru-3630e:runQuery?fields=batch%2Cquery&key=[apikey]

Failed to load resource: the server responded with a status of 401 ()

在 Postman 中尝试时出错
URL : https://datastore.googleapis.com/v1/projects/nammaooru-3630e:runQuery?fields=batch%2Cquery&key=[apikey]

Method : POST


{
"error": {
"code": 401,
"message": "The request does not have valid authentication credentials.",
"status": "UNAUTHENTICATED"
}
}
但我从 Google 开发者网站 得到了回复
https://cloud.google.com/datastore/docs/reference/rest/v1/projects/runQuery#http-request
{
"batch": {
"entityResultType": "FULL",
"entityResults": [
{
"entity": {
"key": {
"partitionId": {
"projectId": "nammaooru-3630e"
},
"path": [
{
"kind": "culture",
"id": "5629499534213120"
}
]
},
"properties": {
"types": {
"stringValue": "",
"excludeFromIndexes": true
},
"images": {
"stringValue": "",
"excludeFromIndexes": true
},
"bname": {
"stringValue": "Kangeyam Kalai"
},
"date": {
"timestampValue": "2017-01-14T12:44:56.933Z"
},
"title": {
"stringValue": ""
},
"description": {
"stringValue": "Coimbatore Kongu nadu region",
"excludeFromIndexes": true
}
}
},
"cursor": "Ci8SKWoRc35uYW1tYW9vcnUtMzYzMGVyFAsSB2N1bHR1cmUYgICAgICAgAoMGAAgAA==",
"version": "1484398012256000"
}
],
"endCursor": "Ci8SKWoRc35uYW1tYW9vcnUtMzYzMGVyFAsSB2N1bHR1cmUYgICAgICAgAoMGAAgAA==",
"moreResults": "NO_MORE_RESULTS"
},
"query": {
"kind": [
{
"name": "culture"
}
]
}
}

最佳答案

--disable-web-security 并通过在窗口“运行”中运行以下命令重新启动chrome:

chrome --allow-file-access-from-files --disable-web-security --user-data-dir

关于angularjs - 如何使用 Angularjs $Http POST 请求访问来自 Google Data Store 的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41748742/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com