Public Sub PostString(url As String,data As String)
Dim fetch As BANanoFetch
Dim fetchOptions As BANanoFetchOptions
Dim fetchResponse As BANanoFetchResponse
Dim jsonObj As Object ' <-----------------------
Dim Error As String
fetchOptions.Initialize
fetchOptions.Method = "POST"
fetchOptions.Body = data
fetchOptions.Headers = CreateMap("Content-type": "application/json; charset=UTF-8")
fetch.Initialize(url, fetchOptions)
Try
SKTools.ShowToast("try","default", 13000, True)
' wait for the response
fetchResponse = BANano.Await(fetch)
' wait for the json part of the response
jsonObj = BANano.Await(fetchResponse.Json) ' <----------------------- this will still crash if you use e.g. var_dumpor anything that returns invalid json
' overkill as we already have the json parsed here, but for demo's sake so we can do a GetString later
Dim json As JSONGenerator
If BANano.IsArray(jsonObj) Then ' <-----------------------
json.Initialize2(jsonObj)
Else
If BANano.IsMap(jsonObj) Then
json.Initialize(jsonObj)
End If
End If
Catch(Error)
SKTools.ShowToast("hata:"&Error,"default", 13000, True)
End Try
End Sub