Fermat
Search
K

Fetch

fetch method starts the process of fetching a resource from the network, returning the response once available through a callback:
fetch [ID] then ([ID]):
[callback]
end
  • Text argument - the URL of the resource you want to fetch:
fetch [text] then ([ID]):
[callback]
end
set api to "https://min-api.cryptocompare.com/data/price?tsyms=USD&fsym=BTC"
fetch api then (response):
print response
end
  • Dictionary argument:
    • url ← text: the URL of the resource you want to fetch.
    • body ← text or dict: any body that you want to add to your request - optional. (Note that a request using the GET or HEAD method cannot have a body)
    • headers ← dict: any headers you want to add to your request - optional.
    • method ← text: the request method, e.g., GET, POST - optional.
    • mode ← text: the mode you want to use for the request, e.g., cors, no-cors, or same-origin - optional.
fetch [dictionary] then ([ID]):
[body]
end
set request to {
"method" to "GET"
"url" to "https://min-api.cryptocompare.com/data/price?tsyms=USD&fsym=BTC"
"headers" to {
"content-type" to "application/json"
}
}
do fetch request then (response):
print response
end
Last modified 1yr ago