Skip to content

Commit

Permalink
Problemas corrigidos
Browse files Browse the repository at this point in the history
  • Loading branch information
GeovaneDev authored Mar 29, 2024
1 parent 14a83a1 commit 357c293
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pages/api/fundamentus/[ticket].js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default async function handler(request, response) {
const isTicketAvailable = stockList.some(stock => stock.ticker === ticket);

if (!isTicketAvailable) {
return res.status(400).json({ error: `Ticket not found in the available list. Go to ${process.env.URL}/api/fundamentus/available` });
return response.status(400).json({ error: `Ticket not found in the available list. Go to ${process.env.URL}/api/fundamentus/available` });
}

const responseAxios = await axios.post(
Expand Down
13 changes: 7 additions & 6 deletions pages/api/fundamentus/dividend.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ import iconv from 'iconv-lite';
export default async function handler(req, res) {
const { ticket } = req.query;

//Verifica se o ticket é uma string
if (typeof ticket !== 'string') {
return res.status(400).json({ error: 'Ticket parameter must be a string' });
}

//Evita do ticket estar vazio
if (!ticket) {
return res.status(400).json({ error: 'Ticket parameter is required' });
}

try {
// Verifica se ticket é uma string
if (typeof ticket !== 'string') {
return response.status(400).json({ error: 'Invalid input. Ticket must be a string.' });
}

ticket = ticket.toUpperCase(); // Converte para maiúsculas
// Converte o ticket para maiúsculas e codifica para URL
const encodedTicket = encodeURIComponent(ticket.toUpperCase());

//Envia o request
const response = await axios.get(`https://statusinvest.com.br/acoes/${encodedTicket}`, {
Expand Down

0 comments on commit 357c293

Please sign in to comment.