How to make HTTP client requests with Deno
Asked Answered
T

1

11

I'm playing around with Deno but I can't find the standard HTTP client.

I also googled "deno http client" which gives me https://deno.land/x/std/http/client/, but the link is broken. Something was indexed by Google and later removed from the repo.

404 - Not Found
This file or directory could not be found.

I found 3rd party libraries soxa and deno-http but I am looking for something standard.

Is there a standard HTTP client for Deno that I am missing?

Tetrastichous answered 16/5, 2020 at 13:15 Comment(0)
C
18

deno implements a variety of Web APIs. To make an HTTP request in deno you use fetch.

const res = await fetch('https://jsonplaceholder.typicode.com/todos/1');
const data = await res.json();

Web APIs are exposed to the global scope the same way they're in the browser. deno aims to be browser compatible whenever it's possible.

You'll also be able to use:

Clamatorial answered 16/5, 2020 at 13:32 Comment(1)
The official deno document about this: deno.land/manual/runtime/web_platform_apisCrispin

© 2022 - 2024 — McMap. All rights reserved.