Simple Fetch-like API for Espruino

The fetch module provides a wrapper around http to provide a simple promise-based page getter.

This module loads the entire webpage into RAM, so while in most cases it'll work fine, for very big queries you may still need to fall back to http to handle the data in a streaming manner.


const http = require('http');
const fetch = require('fetch.js')(http);


const fetch = require('fetch.js')() //defaults to using 'http' module

(eventually, using 'tls' module instead of 'http' will be supported, hopefully)


fetch(url, params).then(response => response.text()).then(text=>{
//do stuff with text
// e.g. console.log(text)

url should look like: '' params are optional, but should look like:

const params = { method: 'GET'(default) or 'PUT' or 'POST' or 'DELETE', body: String //(for PUT/POST) ...any other params that you'd supply to http.request() }

Working examples:

fetch('', {
  method: 'POST', 

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.