小编use*_*440的帖子

FetchError:无效的 json 响应正文

我正在使用 node-fetch 将一些 json 数据发送到 IFTTT 休息点。数据已成功发送到端点,但我的 NodeJS 控制台出现错误。如您所见,它返回 undefined 然后说有一个无效的 json 响应正文。我检查了身体,对我来说看起来很好。

问题是什么?

  async function checkTemperatureRange() {
    try {
      const temperatureSettings = await getTemperatureSetting();
      const currentTemperature = await getCurrentTemperature();

      if (currentTemperature < temperatureSettings.min_temp || currentTemperature > temperatureSettings.max_temp) {
        console.log('Temp NOT in range!');
        const body = { value1: currentTemperature };
        fetch('https://maker.ifttt.com/trigger/temp_reading/with/key/abc123', {
          method: 'post',
          body:    JSON.stringify(body),
          headers: { 'Content-Type': 'application/json' },
        })
        .then(function (res) {
          res.json()
        })
        .then(function (json) {
          console.log(json)
        })
        .catch(function (err) {
          console.log('node-fetch error: ', err)
        }); …
Run Code Online (Sandbox Code Playgroud)

node.js node-fetch

4
推荐指数
1
解决办法
2万
查看次数

如果值相同,UPDATE 是否会覆盖它们?

我只想更新数据库中的值(如果不同)。阅读有关 UPDATE 的 Oracle 文档,它说......

...UPDATE 语句用值更新指定表中现有行的列。

既然它没有说它不会覆盖相同的值,我应该从字面上理解这个说法吗?这是否意味着 MySQL 会为我进行某种布尔匹配检查?

mysql

3
推荐指数
1
解决办法
1720
查看次数

标签 统计

mysql ×1

node-fetch ×1

node.js ×1