Queried WebClient

Letting the client do the work.

This component makes working with requests a little easier in introducing a somewhat async workflow by taking a request on  one after another with an extensive API. 
It makes life a little easier by autoparsing requests and responses to JSON.

Parameters:
  • Server : The base domain all requests will be appended to.

Methods:
  • QueryRequest(request_dict : Dictionary): Takes a dictionary and appends it to the queue and fires it off if nothing is requesting at the moment. The Dict needs to be formatted the following way:
    method: HTTP Request method as a string. ("GET", "POST", ...)
    url: The target  URL including query-params.
    header: The header as a Dictionary.
    body: The data you want to send in the requestbody.
    callback: A method taking one argument that gets called when the request returns a success.
  • MultipartFormData( dictionary ): Returns the dictionary as multipart-formdata in bytes. Header needs to be set manually.
  • Get( endpoint: string, params: Dict, header: Dict, callback: function) : Query a get request. Except endpoint everything else is optional.
  • Post,Put,Delete(  endpoint: string, params: Dict, header: Dict, callback: function, data ): Creates a Post/Put/Delete request.
    If the data is delivered as a dictionary, it will be converted to JSON and the apllicationtype Json will be applied to the header.

For get one page of catbreeds from catfact.ninja and print it out call:

op("queriedWebClient").Get("breeds", 
params = {"limit" : 1},
callback = lambda response: debug(response))

Downloads: 25

Created at: 6.8.2021

Uploaded: 6.8.2021
Added timeout parameter and better exampleurl.
Download