powered by simpleCommunicator - 2.0.18     © 2024 Programmizd 02
Map
Форумы / Серверный JavaScript (Node.js, Ringo, Nitro, Sling) [игнор отключен] [закрыт для гостей] / ошибка UnhandledPromiseRejectionWarning: TypeError: response.json is not a function
1 сообщений из 1, страница 1 из 1
ошибка UnhandledPromiseRejectionWarning: TypeError: response.json is not a function
    #40016793
erleug
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Пытаюсь получить данные с базы

Код: javascript
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
export async function Otdel() {
    try {
        const cards = await sequelize.query(
            'select * from sta_otdel',
            {
                type: QueryTypes.SELECT,
            },
        );

        if (!cards) {
            return { success: false, error: ErrorCode.notFound };
        }

        return {
            success: true,
            content: cards,
        };
    } catch (error) {
        console.log(error.message);
        return { success: false, error: ErrorCode.unexpectedError };
    }
}



Код: javascript
1.
2.
3.
4.
async function tableDocuments(response: Response) {
  const data = await incomingService.tableDocuments.Otdel()
  return response.json(data)
}



На клиенте получаю с помощью axios

Код: javascript
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
const response = await axios.get(`/incoming/tableDocuments`, {
      headers: { authorization: "Bearer " + User.token },
      cancelToken: tableDocumentsCancelToken.token,
    })

    if (response.data?.success) {
      return {
        type: "ok",
        content: response.data.content,
        info: response.data.info,
      }
    }



Подскажите пожалуйста, в чем ошибка?
...
Рейтинг: 0 / 0
1 сообщений из 1, страница 1 из 1
Форумы / Серверный JavaScript (Node.js, Ringo, Nitro, Sling) [игнор отключен] [закрыт для гостей] / ошибка UnhandledPromiseRejectionWarning: TypeError: response.json is not a function
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали тему (1): Анонимы (1)
Читали форум (1): Анонимы (1)
Пользователи онлайн (8): Анонимы (6), Yandex Bot, Cat2 1 мин.
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]