由于某种原因,职位的endDate挂起了整个脚本?
function importJobsEducation() {
IN.API.Profile("me")
.fields(["id","positions:(company,title,summary,start-date,end-date,is-current)", "educations","skills", "headline"])
.result(function(result) {
profile = result.values[0];
$("#headline").val(profile.headline);
$("#linkedInID").val(profile.id)
positions = "";
for (var index=0; index < profile.positions.values.length; index++) {
JobTitle = profile.positions.values[index].title
jobSummary = profile.positions.values[index].summary
isCurrent = profile.positions.values[index].isCurrent
JstartMDate = profile.positions.values[index].startDate.month
JstartYDate = profile.positions.values[index].startDate.year
alert(profile.positions.values[index].endDate.month)
if (isCurrent === false) {
}
// Company Fields
OrgName = profile.positions.values[index].company.name
companyType = profile.positions.values[index].company.companyType
size = profile.positions.values[index].company.size
industry = profile.positions.values[index].company.industry
ticker = profile.positions.values[index].company.ticker
}
education = "";
for (var index=0; index < profile.educations.values.length; index++) {
schoolName = profile.educations.values[index].schoolName
startDate = profile.educations.values[index].startDate.year
EndDate = profile.educations.values[index].endDate.year
}
skills = "";
for (var index=0; index < profile.skills.values.length; index++) {
skills += '<a href="" class="tag">'+ profile.skills.values[index].skill.name + '</a> ';
}
});
}
答案 0 :(得分:1)
您的代码存在的问题是当前位置没有结束日期,编写代码的方式会尝试获取endDate,即使是当前位置。
因此,我建议你有一个条件标签来检查这个位置是否是最新的,如果不是,它会取出结束日期。例如:
if (profile.positions.values[index].isCurrent === false) {
endDate = profile.positions.values[index].endDate.month;
}
我希望这会有所帮助。