遇到的问题
今天打开obsidian,用templater的模板创建日记时发现,模板代码不工作,右上角提示:
Templater Error:
Templater parsing error, aborting. Check console for more information.
打开控制台,发现点击calendar的日期创建日记时,控制台报错:
最近并没有对日记模板进行过修改,请教是什么原因造成的?
日记模板涉及js的就是简单的地理位置和天气数据调用:
<%*
let weatherUrl = ‘https://restapi.amap.com/v3/weather/weatherInfo’
let key = ‘(已隐藏)’
let ipUrl = ‘https://restapi.amap.com/v3/ip’;
let ipResult = JSON.parse(await request({url: ipUrl + ‘?key=’ + key, method: “GET”}))
console.log("ipResult: ", ipResult)
let adcode = ipResult.adcode
console.log("adcode: " + adcode)
let 位置 = ‘’
let 天气 = ‘’
let 温度 = ‘’
let 风向 = ‘’
await fetch(weatherUrl + ?key=${key}&city=${adcode}&extensions=all
)
.then(res => res.json())
.then((data) => {
let info = data.forecasts[0]
console.log("info:" + info)
位置 = info.province + '-' + info.city
天气 = '🌅' + info.casts[0].dayweather + ' / 🌃' + info.casts[0].nightweather
温度 = '🌅' + info.casts[0].daytemp_float + '℃' + '/ 🌃' + info.casts[0].nighttemp_float + '℃'
})
-%>