🚀
Empathize
  • Introduction
  • Installation
  • API
    • Paths API
      • Directories
      • Paths
    • Filesystem API
      • Filesystem
    • Windows API
      • Windows
    • OS API
      • Process
      • Tray
      • IPC
      • Notification
      • Archive
      • Package
    • Network API
      • fetch
      • Domain
      • Downloader
    • Async API
      • promisify
    • Meta classes
      • Cache
      • Configs
      • Debug
  • Building application
Powered by GitBook
On this page
  • Response object
  • response.body(delay)
  • fetch function
  • fetch(url, delay)
  1. API
  2. Network API

fetch

Response object

Property
Type
Description

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}`);
});
PreviousNetwork APINextDomain

Last updated 3 years ago