javascript - 将有效负载添加到 axios 请求
问题描述
我对我的 axios 请求有一些疑问。要从 API 获取信息,我的请求中需要一个密钥和一个秘密 - 在我的示例中这是否正确实施,我在哪里可以找到正确的密钥/秘密?
以及如何向我的 axios 请求添加有效负载以获得对该请求的特定答案?
var my_url = "https://secret.de";
var myResponse = "";
function My(axios) {
this.axios = axios;
this.vue = this.getMyResponse();
this.vue.getData();
}
My.prototype.getMyResponse = function() {
var myRequest = new Vue({
headers: {
"consumerKey": "key",
"consumerSecret": "secret",
},
el: '#widget1',
method: 'post',
data: {
myResponseData: ''
},
methods: {
getData: function () {
axios.all([
axios.post(my_url, {
username: "username",
password: "password"
})
])
.then(axios.spread(function (myResponseOne) {
myWidget(myResponseOne);
myRequest.$data.myResponseData = myResponse;
}))
}
},
});
timeout = setInterval(myRequest.getData, 60000);
return myRequest;
};
谢谢!
解决方案
推荐阅读
- git - 在不获取其他分支的情况下增加浅克隆的深度
- javascript - 如何从数组中获取范围滑块内的值
- php - PDO 插入不接受“真”或“假”,但只接受 0 和 1
- c# - 实体框架并非全部检测模型上的更改
- mysql - 如何使用 ROW_NUMBER() 将行号添加到 MySQL 显示
- powershell - 在 Active Directory AD Powershell 中再次运行脚本
- angular - 如何增加ngbmodal的宽度
- ngrx - 如何破译ngrx API
- javascript - 如何在类外调用类内的函数
- talend - 在 talend Studio 之外编辑工作