Promises in fetch
See original GitHub issueA month ago I started creating my own wiki/parser but as you know it’s a big pain in the ass. So I decided colaborate with another library, yesterday I found this one and I think is a great start. My idea is helping you with this, but I think we have different code-styles, and before start send you PRs I wanna tell you my thoughts:
- Why we need more than one method? Now we have
plaintext
,from_api
andparse
. IMHO this library must be a unique stateless method:
import wikipediaWTF from `wikipedia-wtf`;
wikipedia(sentence {string}, options {language...})
- Why we dont use
Promises
like?Better if we use something like:
wikipedia.from(sentence, options)
.then(value => ...)
.catch(error => ...)
- If it’s a promise we can use the new standard
async/await
:
const knowledge = await wikipedia(sentence, options);
- IMHO is better approach auto-parse the markup to a JavaScript Object
- Now we have
infobox
andinfobox_template
, why we dont create a unique attribute?** - And the last one (for now), why we use
grunt
?? Maybe we have to move tobabel
+mocha
via NPM tasks (zero-dependencies)
I think this library is a great start, but we have to create an consistent DSL for a better experience using it.
best,
javi
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:9 (6 by maintainers)
Top Results From Across the Web
How to make HTTP requests using Fetch API and Promises
The fetch function takes one mandatory argument, which is the path to the resource you want to fetch and returns a Promise that...
Read more >How To Use JavaScript Promises and Fetch API - Andolasoft
Fetch () allows you to make network requests similar to XMLHttpRequest (XHR). The main difference is that the Fetch API uses Promises, ...
Read more >fetch() - Web APIs | MDN
A fetch() promise only rejects when a network error is encountered (which is usually when there's a permissions issue or similar). A fetch() ......
Read more >Promise API - The Modern JavaScript Tutorial
map(url => fetch(url)); // Promise.all waits until all jobs are resolved Promise.all(requests) .then( ...
Read more >Using fetch() and a new Promise object to get API results
I've written an ES6 function using the new fetch() API and returning a new resolved promise with a data object or a rejected...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hey all! this is implemented in 3.0.0
🎸
Spencer you are great, wonderful to have this library and other people seeing the value of your work. cheers, Bert