【发布时间】:2019-05-14 22:25:14
【问题描述】:
我正在设置一个服务器,我需要使用 Google 语音 API 来将音频翻译成文本。 该服务器向 Google 的 API 发送一个 post 请求并检索操作的 NAME(ID)。然后我尝试使用 NAME(ID) 发出获取请求以检索数据,但出现 404 错误。
我已经尝试将 api.get('/v1p1beta1/operations/{NAME}') 与 Google 的 API KEY 一起使用,例如 api.get('/v1p1beta1/operations/{NAME}?key={ key}') 但后来我收到了一个错误的请求。 这段代码也有效,但停止了,我不知道为什么。
const api = await axios.create({
baseURL: 'https://speech.googleapis.com',
crossDomain: true,
responseType: 'json',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': "Bearer <<TOKEN>>"
},
});
// calling api
api.get('/v1p1beta1/operations/{NAME}')
.then(resp=>{
console.log( resp);
}).
catch('error');
})
【问题讨论】:
标签: google-speech-api get-request