56 lines
1.3 KiB
QBasic
56 lines
1.3 KiB
QBasic
Attribute VB_Name = "http"
|
|
|
|
Sub pull_months(doc As String)
|
|
|
|
Dim req As New WinHttp.WinHttpRequest
|
|
Dim wapi As New Windows_API
|
|
Dim wr As String
|
|
Dim json As Object
|
|
Dim i As Long
|
|
|
|
|
|
|
|
With req
|
|
.Open "GET", "http://10.56.1.108:3000/monthly_orders", True
|
|
'.Open "GET", "http://192.168.1.69:3000/monthly_orders", True
|
|
.SetRequestHeader "Content-Type", "application/json"
|
|
.Send doc
|
|
.WaitForResponse
|
|
wr = .ResponseText
|
|
End With
|
|
|
|
Call wapi.ClipBoard_SetData(wr)
|
|
|
|
'MsgBox (wr)
|
|
|
|
On Error GoTo jerr
|
|
|
|
Set json = JsonConverter.ParseJson(wr)
|
|
|
|
jerr:
|
|
If Err.Number <> 0 Then
|
|
MsgBox ("function call error:" & vbCrLf & wr)
|
|
Exit Sub
|
|
End If
|
|
|
|
On Error GoTo errh
|
|
|
|
Sheets("test").range("A2:D1000").ClearContents
|
|
Sheets("test").range("N3:Q14").ClearContents
|
|
|
|
For i = 1 To json("jsonb_agg").Count
|
|
Sheets("test").Cells(i + 1, 1) = json("jsonb_agg")(i)("oseas")
|
|
Sheets("test").Cells(i + 1, 2) = json("jsonb_agg")(i)("monthn")
|
|
Sheets("test").Cells(i + 1, 3) = json("jsonb_agg")(i)("qty")
|
|
Sheets("test").Cells(i + 1, 4) = json("jsonb_agg")(i)("sales")
|
|
Next i
|
|
|
|
Sheets("test").Select
|
|
|
|
errh:
|
|
If Err.Number <> 0 Then
|
|
MsgBox (Err.Description)
|
|
End If
|
|
|
|
End Sub
|