sketchfetch

1.0.2 • Public • Published

sketchfetch

npm Sketch.app

~= fetch for Sketch, using Futures

import fetch from 'sketchfetch';

fetch('https://reqres.in/api/users').fork(
  err => log('error, fella'),
  res => {
    log('result!');
    log(res);
  }
);
// 'result!'
// { data: […] }

fetch('https://reqres.in/api/users', {
  method: 'POST',
  body: {
    'name': 'Matthew McConaughey'
  }
}).fork…

Remember to call fork(err => err, result => result) on the returned Future to run it!

Rationale

  • sketch's JS runtime doesn't support fetch or XMLHttpRequest so we can't use any normal polyfills
  • NSURLConnections take a ton of code to set up
  • no time for that…

TODOs

  • [ ] list out unsupported cases
  • [ ] switch to async requests

Readme

Keywords

none

Package Sidebar

Install

npm i sketchfetch

Weekly Downloads

0

Version

1.0.2

License

MIT

Last publish

Collaborators

  • jongold