代码之家  ›  专栏  ›  技术社区  ›  AlbertMunichMar

栏杆。视图trips/1,在视图中我有一个承诺,当它被解决时,我被重定向到trips/[object%20Object]

  •  0
  • AlbertMunichMar  · 技术社区  · 7 年前

    我在trips/1中(在trip的显示页中)。我从Google调用了地理编码API:

    <script>
      const url = "https://maps.googleapis.com/maps/api/geocode/json?address=munich&key=AIzaaaabo"
    
      fetch(url).then(response =>
        response.json().then(data => ({
            data: data,
            status: response.status
        })
      ).then(res => {
        location = res.data.results[0].geometry.location;
      }));
    </script>
    

    http://localhost:3000/trips/[object%20Object]

    我真的不明白发生了什么。

    谢谢

    1 回复  |  直到 7 年前
        1
  •  0
  •   Ravi Teja Dandu    7 年前

    照此 https://www.w3schools.com/js/js_reserved.asp , location 是保留关键字。如注释中所述,将变量赋值为 位置 有办法。很乐意帮忙。

    推荐文章