Git Product home page Git Product logo

fieldclimate's People

Contributors

gaazkam avatar marborowiec avatar satagro avatar

Watchers

 avatar  avatar  avatar

Forkers

marborowiec

fieldclimate's Issues

javascript support?

good evening. i didnt manage to make javascript fetch data from the API.
any chance to make it work ?

For now , i got this code:


	var pub_key = "xxx";
        var priv_key = "yyy";
 	  
	var dateStamp = "Fri, 03 Jan 2020 21:57:10 GMT";
	var content = "GET"+"/user"+dateStamp+pub_key;
	var hash = CryptoJS.HmacSHA256(content, priv_key);
	//var hashInBase64 = CryptoJS.enc.Base64.stringify(hash);

	var tmpstr=hash+"";

	var authStr =  "hmac " + pub_key +":" + tmpstr;
      let API_LINK = "https://api.fieldclimate.com/v1/user";
	console.log("=============");
	console.log("hmac "+pub_key+":"+tmpstr);
      fetch(API_LINK, {
        method: "GET",
        headers: {
		"Accept":"application/json",
		"Authorization":authStr
		
	}
      })
       //response => response.ok ? response.json() : Promise.reject(response)
      .then(response => {console.log(response)})
      .then(data => {console.log(data)})
      .catch( error => {console.log(error)})
	

But i get 401 response code :/

Czy w odpowiedzi serwera na user/licenses mogą pojawić się zduplikowane klucze i jeśli tak, to jak to obsłużyć?

Czytam dokumentację API i jedno mnie mocno dziwi:

Oto podana przez nich przykładowa odpowiedź na zapytanie GET /user/licenses:

{
    "models": {
        "CROP": {
            "STATION-ID": [
                {
                    "from": "DATE-TIME",
                    "to": "DATE-TIME"
                }
            ],
             "STATION-ID": [
               {
                   "from": "DATE-TIME",
                   "to": "DATE-TIME"
               }
            ],...
        },
        "CROP": {
            "STATION-ID": [
                {
                    "from": "DATE-TIME",
                    "to": "DATE-TIME"
                }
            ],
             "STATION-ID": [
               {
                   "from": "DATE-TIME",
                   "to": "DATE-TIME"
               }
            ],...
        },...
    },
    "Forecast": {
        "STATION-ID": [
            {
                "from": "DATE-TIME",
                "to": "DATE-TIME"
            }
        ],
        "STATION-ID": [
            {
                "from": "DATE-TIME",
                "to": "DATE-TIME"
            }
        ],...
    }
}

Jeśli dobrze widzę, to klucz "CROP" jest zduplikowany. Czy to w ogóle jest poprawny JSON?

Jeśli takie odpowiedzi mogą przychodzić, to jak je obsłużyć?

Z tego, co rozumiem, to biblioteka winna po prostu zwrócić słownik Pythonowy powstający ze sparsowania JSON-a, tak? Ale przecież słownik nie może zawierać zduplikowanych kluczy?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.