我正在使用 fetch to wordpress api 发出请求,但我在响应中得到一个空的 headers 对象,有人知道为什么吗?
这是我的提取操作
export const getJobs = () => {
return dispatch => {
fetch(endpoints.jobs)
.then(res => res.json())
.then(data => dispatch(setJobs(data)))
}
};
Run Code Online (Sandbox Code Playgroud)
这是我在做 res.json 之前得到的对象
body: (...)
bodyUsed: false
headers: {}
ok: true
redirected: false
status: 200
statusText: "OK"
type: "cors"
url: "url"
Run Code Online (Sandbox Code Playgroud)
关于如何从响应中获取所有标题的任何想法?
我正在本地存储中保存一个对象,并且我想在再次加载页面时列出所有项目,但我不知道如何从对象元素中获取信息。有任何想法吗?这是我的代码:
var estudiantes = [];
function agregaArray(i) {
estudiantes.push({
"carnet": $("#carnet_" + i).text(),
"apellidos": $("#apellidos_" + i).text(),
"nombre": $("#nombre_" + i).text(),
"e1": $("#examen1_" + i).val(),
"e2": $("#examen2_" + i).val(),
"e3": $("#examen3_" + i).val(),
"prom": $("#promedio_" + i).text()
});
}
function agregaLocalStorage() {
localStorage.setItem("114270311_estudiantes", JSON.stringify(estudiantes));
}
$("#list").click(function () {
for (var i = 0; i < localStorage.length; i++) {
var obj = JSON.parse(localStorage.getItem(localStorage.key(i)));
console.log(obj.carnet);
console.log(obj.apellidos);
console.log(obj.nombre);
}
});
Run Code Online (Sandbox Code Playgroud)
这些 console.logs 返回“未定义”,我想获取具体信息。
谢谢您的帮助。
我正在尝试向我的步骤函数状态机添加一些错误处理,并且我在特定情况下遇到了问题,例如,如果我在某个步骤上失败,我有一个捕获将其发送到另一个函数,但是在该函数我需要使用最后一步输入数据(失败的数据)执行逻辑,但是,我刚刚收到一个错误,有没有办法传递带有错误的输入数据?
Send Notification:
Type: Task
Resource: !GetAtt CommunicationSendCertifiedEmail.Arn
Retry:
- ErrorEquals:
- TierOneError
IntervalSeconds: 2
MaxAttempts: 9
BackoffRate: 1.5
- ErrorEquals:
- TierTwoError
IntervalSeconds: 4
MaxAttempts: 6
BackoffRate: 1.5
- ErrorEquals:
- TierThreeError
IntervalSeconds: 4
MaxAttempts: 3
BackoffRate: 2
- ErrorEquals:
- States.Timeout
- States.Runtime
- States.TaskFailed
- Lambda.ServiceException
IntervalSeconds: 4
MaxAttempts: 3
BackoffRate: 2
Catch:
- ErrorEquals:
- States.ALL
Next: Send Email Notification
Run Code Online (Sandbox Code Playgroud)
在“发送电子邮件通知”上,我需要在执行失败之前输入,但正如我之前所说,我只是得到这样的信息:
{
"Error": "Error",
"Cause": "{\"errorType\":\"Error\",\"errorMessage\":...
}
Run Code Online (Sandbox Code Playgroud)
我想要得到这样的东西:
{
"data": "{...}",
"Error": "Error",
"Cause": "{\"errorType\":\"Error\",\"errorMessage\":...
} …Run Code Online (Sandbox Code Playgroud)