account0123 / rae-api Goto Github PK
View Code? Open in Web Editor NEWRAE API i modified from https://github.com/mgp25/RAE-API to nodejs
License: MIT License
RAE API i modified from https://github.com/mgp25/RAE-API to nodejs
License: MIT License
Hola, me encanta y me es super útil tu API.
¿Crees que podrías implementar una función que te de una palabra aleatoria o cómo crees que se podría hacer?
Un saludo.
Buenas, haciendo una gran cantidad de peticiones para obtener una palabra aleatoria me he encontrado con el siguiente error:
const h = body.match(/<header [^>]*>([^<]+)/)[1]
^
TypeError: Cannot read properties of null (reading '1')
at IncomingMessage.<anonymous> (lorem\node_modules\rae-api\src\HttpInterface.js:56:51)
at IncomingMessage.emit (node:events:402:35)
at endReadableNT (node:internal/streams/readable:1343:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Según una pequeña revisión, llegué a la conclusión de que el problema ocurre porque el header incluye una etiqueta de cursiva "< i >" para envolver la palabra a definir, la cual evita que la función regExp encuentre el texto correspondiente y por lo tanto el método .match retorna un valor null.
Personalmente estoy intentando cambiar la función regExp para que permita seleccionar en los casos en que se cumpla esta condición pero tengo nula experiencia utilizando estas expresiones, si logro solucionarlo publicaré el cambio que realicé.
En caso de que tenga relevancia, lo único que estoy haciendo es ejecutar múltiples veces la función getRandomWord. Algunas veces logra ejecutarse 200 veces sin encontrar una palabra que produzca el problema pero en la mayoría de veces ocurre antes de llegar a ese punto. Todo lo que estoy ejecutando es:
const words = [];
async function randomWord() {
const random = await rae.getRandomWord();
const rWord = random.getHeader();
words.push(rWord);
}
async function iterate() {
for (let i = 0; i < 200; i++) {
if (i % 10 == 0) {
console.log(i);
}
await randomWord();
}
console.log(words);
}
iterate();
Gracias de antemano.
HTTP request returns 403
Estoy utilizando la api, que es muy útil por cierto :)
Pero tengo un problema con el método fetchWord, si el id es incorrecto no encontré la manera de manejar el error y se cae la app.
Desarrollo en typescript ya probé con try catch ó fetchWord().catch() pero nada
Gracias!!
I noticed that an API key Auth token is hardcoded in Constants.js. Wouldn't it make more sense for us to provide our own?
e.g.
const rae = new RAE({ debug: false, authToken: "Basic FOOBAR" });
Recently trying to consume from this API project, we found that searching for words that contain italic tags fails.
So what we're basically trying to do, following the current documentation is to:
rae.fetchWord(response.getRes()[0].getId()))
What throws an error of body.res is not iterable
We try with Pizza and Paparazzi words and get the same result, the only reason we reach that this could be happening is related to the italic tags in the header word when trying to fetch the ID of the word.
Estoy usando el example GetDefinition.js en la última versión en Node.js v18.15.0, al hacer una búsqueda con una palabra con varias formas (ajo, champán, ...) resulta en un error:
const h = body.match(/<header .+>([^<]+)(<\/i>)?<\/h/)[1]
^
TypeError: Cannot read properties of null (reading '1')
at IncomingMessage.<anonymous> (C:\Users\niwlf\OneDrive\Escritorio\Github\letras\node_modules\rae-api\src\HttpInterface.js:60:60)
at IncomingMessage.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)```
reject(error)
should be reject(err)
or it masks the real error!
Lines 73 to 76 in a9d31e9
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.