Skip to content

Conversation

@mikesoylu
Copy link

Vibe coded fetch implementation:

// GET request
var response = fetch(url);

// With options
var response = fetch(url, {
    method: "POST",           // GET, POST, PUT, DELETE, etc.
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer token",
        "Accept": "application/json"
    },
    body: JSON.stringify(data)
});

// Response object
response.status      // HTTP status code (200, 404, etc.)
response.ok          // true if status is 200-299
response.statusText  // status as string
response.headers     // object with lowercase header names
response.body        // response body as string

Example Usage

// Fetch JSON API
var response = fetch("https://api.example.com/data");
if (response.ok) {
    var data = JSON.parse(response.body);
    console.log(data);
}

// POST with JSON
var response = fetch("https://api.example.com/submit", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ name: "test" })
});

@bellard
Copy link
Owner

bellard commented Dec 24, 2025

mquickjs is intended to stay small so it is not possible to add a large standard library. Maybe doing that in another repository or as an example would be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants