fetch

Response object

PropertyTypeDescription

url

string

Requested URL

status

number | null

Response status code

length

number | null

Response content length

ok

boolean

Response status (true if code within 200-299, otherwise false)

response.body(delay)

Request body content

fetch function

fetch(url, delay)

import { fetch } from '@empathize/framework';

// https://ipinfo.io/developers
fetch('https://ipinfo.io').then((response) => {
    if (response.ok)
    {
        console.log(`OK: ${response.status}`);
        
        response.body().then((body) => {
            console.log(`Your IP: ${JSON.parse(body).ip}`);
        });
    }
    
    else console.log(`Error: ${response.status}`);
});

Last updated