Navigation

    Windy Community

    • Register
    • Login
    • Search
    • Unread
    • Categories
    • Groups
    • Go to windy.com
    1. Home
    2. Marcelklim
    3. Posts
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Groups 0

    Posts made by Marcelklim

    • RE: Javascript fetch

      @marekd

      thx, but i changed the key efore posting avoiding abuse of my key. at this moment i still can't get the fetch done. the plugin is webbased? I try to get it done with javascript on a computer

      posted in Developers
      M
      Marcelklim
    • Javascript fetch

      I am trying to fetch the windy data, but get an error;
      Unexpected token W in JSON at position 0
      at /node_modules/node-fetch/lib/body.js:48:31
      at processTicksAndRejections (internal/process/task_queues.js:97:5) {
      name: 'FetchError',
      message: 'invalid json response body at https://api.windy.com/api/point-forecast/v2 reason: Unexpected token W in JSON at position 0',
      type: 'invalid-json'

      What could be the problem in my script?

      let _data = { 
      "lat": 52.046,
      "lon": 4.447,
      "model": "iconeu",
      "parameters": ["wind"],
      "levels": ["surface"],
      "key": "..."};
      

      fetch("https://api.windy.com/api/point-forecast/v2", {
      method: 'POST',
      body: _data,
      headers: {"Content-type": "application/json; charset=UTF-8"}
      })
      .then(response => response.json())
      .then(Server => {
      console.log(Server) // Prints result from response.json()
      // var UvNow = Server.result.uv;//Processing UVToday
      // BLApp.apiPut("UvNow/"+UvNow);//Updating better logic variable UVToday
      })
      .catch(error => console.error(error))
      // OpenUvServer = false
      // var StandardProcessing = false
      // console.log("i is: " +i)

      posted in Developers
      M
      Marcelklim