Skip to content

Commit b09b60c

Browse files
authored
fix: url encoding (#1142)
The Wolframalpha API call would previously throw an error due to an incorrect layout of the input data to the url encoding step. This commit fixes it
1 parent f0cd46c commit b09b60c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
let appID = "" #YOUR APP_ID
1+
let appID = $env.WOLFRAMALPHA_APPID
22

33
#Fetch simple answer from WolframAlpha API
4-
def wolfram [...query #Your query
4+
def wolfram [...query
55
] {
66
let query_string = ($query | str join " ")
7-
let result = (http get ("https://api.wolframalpha.com/v1/result?" + ([[appid i]; [$appID $query_string]] | url build-query)))
7+
let result = (http get ("https://api.wolframalpha.com/v1/result?" + ([[key value]; [appid $appID] [i $query_string]] | url build-query)))
88
$result + ""
99
}
1010

1111
#Fetch image with full answer from WolframAlpha API
12-
def wolframimg [...query #Your query
12+
def wolframimg [...query
1313
] {
1414
let query_string = ($query | str join " ")
1515
let filename = ($query_string + ".png")
16-
let link = ("https://api.wolframalpha.com/v1/simple?" + ([[appid i]; [$appID $query_string]] | url build-query) + "&background=F5F5F5&fontsize=20")
16+
let link = ("https://api.wolframalpha.com/v1/simple?" + ([[key value]; [appid $appID] [i $query_string]] | url build-query) + "&background=F5F5F5&fontsize=20")
1717
http get $link | save $filename
1818
echo ("Query result saved in file: " + $filename)
1919
}

0 commit comments

Comments
 (0)