> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/async/promise/custom-promises/getjson.md).

# getJSON()

[JS](/web/js.md) ⟩ [async](/web/js/async.md) ⟩ [Promise](/web/js/async/promise.md) ⟩ getJSON()

{% tabs %}
{% tab title="💾 程式" %}

```javascript
function getJSON(url) { 
    return fetch(url).then(response => response.json()); 
}
```

{% endtab %}

{% tab title="📘 手冊" %}

* [fetch()](https://developer.mozilla.org/en-US/docs/Web/API/fetch) - returns [Promise](/web/js/async/promise.md) that resolves to the [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object
* [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) ⟩ [.json()](https://developer.mozilla.org/en-US/docs/Web/API/Response/json) - returns [Promise](/web/js/async/promise.md) which **resolves** with the <mark style="color:yellow;">**result of parsing**</mark> the body text as [`JSON`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON).
* [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) ⟩ [.then()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) - returns [Promise](/web/js/async/promise.md)
  {% endtab %}
  {% endtabs %}
