Comments (5)
Por nada! Consegui fazer a requisição, valeu Thiago 👍
from dicio-api.
Opaa, boa noite! Como está fazendo a request? Vou tentar reproduzir o erro aqui
from dicio-api.
Estava tentando fazer a requisição por AJAX
from dicio-api.
Segue a função que estou tentando utilizar:
function openDicionario() {
var selectedText = window.getSelection().toString();
if (selectedText.trim().split(' ').length > 1) {
$.fancybox.open(document.getElementById('erroDicionario'));
}
else {
$.fancybox.open(document.getElementById('dicionario'));
$('.container__dicionario-title').text("Significado para: " + selectedText);
$('.box__dicionario').empty();
$('.box__dicionario').html('<br /><div class="loader center"></div>');
$.ajax({
type: "GET",
url: "https://significado.herokuapp.com/" + selectedText,
success: function (response) {
var definitions = loopThrough(response[0]);
$('.loader').hide();
if (definitions.length > 0) {
definitions.forEach(fillIn);
}
else {
$('.box__dicionario').append(html);
var html = "<p class='box__dicionario-descricao'>Nenhum resultado encontrado";
$('.box__dicionario').append(html);
}
},
error: function (e) {
$('.loader').hide();
$('.box__dicionario').append(html);
var html = "<p class='box__dicionario-descricao'>Nenhum resultado encontrado";
$('.box__dicionario').append(html);
}
});
}
function loopThrough(data, timesToTry = 5) {
var keys = Object.keys(data);
for (var k of keys) {
// console.log("valor",k);
if (k === "meanings") {
if (typeof data[k] === "object") {
var substantivos = Object.keys(data[k]);
if (substantivos.length > 0) {
return data[k][substantivos[0]];
}
}
}
}
}
function fillIn(item, index) {
var html = "<p class='box__dicionario-descricao'><strong>" + (index + 1) + "</strong>. " + item.definition + "</p><p class='box__dicionario-linha'></p >";
$('.box__dicionario').append(html);
}
}
from dicio-api.
Corrigido, obrigado por reportar!
from dicio-api.
Related Issues (20)
- Algumas palavras estão retornando undefined
- Consumo de API
- Rota de sinônimos retorna também os antônimos da palavra.
- Rota /sentences está retornando caracteres `\n` no meio da string.
- Impossibilidade de retorno de significados de palavras com grafia igual mas acentuação diferente. HOT 2
- Criar testes
- Palavras com diferentes acentuações não podem ser retornadas ao usar allMeanings HOT 3
- Palavras que são apenas acentuadas não podem ser encontradas ao usar versão acentuada para obter dados HOT 1
- Chamadas sem partOfSpeech HOT 3
- API não funciona (heroku error)
- Multiplas palavras
- API Off HOT 3
- Ideia de dados na API HOT 1
- Consulta de api HOT 1
- API fora do ar HOT 1
- Recuperar múltiplos sentidos de sinônimos HOT 1
- Erro de CORS
- API fora do ar HOT 5
- Erro 503 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dicio-api.