{
  "id": "fn-net-fetch",
  "dataComponent": "net",
  "heading": {
    "title": "fetch",
    "badges": [
      "Network",
      "ASYNC"
    ]
  },
  "synopsis": "Performs an HTTP GET request to the given URL, then invokes the callback with the response body.",
  "codeBlocks": [
    "extend(\"net\")\\n\\n# net:fetch usage\\nnet:fetch(\"https://example.com\", body => {\\n  sput(body)\\n})\\n\\n# Partial usage is not applicable here. net:fetch expects exactly two arguments:\\n# 1) The URL\\n# 2) A callback function that receives the response body\\n\\n# Example callback that prints the length of the result\\nnet:fetch(\"https://example.org\", data => {\\n  sput(string:concat(\"Length is \", string:to_string(array:length(data))))\\n})"
  ],
  "notes": [
    "The first argument must be a single string representing the URL.",
    "The second argument must be a function (callback) that takes one argument (the response body as a single string).",
    "net:fetch runs asynchronously, returning immediately with a boolean (true). The actual network request occurs in the background.",
    "When the fetch completes, your callback is called with the raw response body. If the request fails, the callback receives a string describing the error."
  ]
}
