Skip to content

Использование fetch вместо https - #5

Open
batkor wants to merge 1 commit into
mike1pol:masterfrom
batkor:master
Open

batkor wants to merge 1 commit into
mike1pol:masterfrom
batkor:master

Conversation

@batkor

@batkor batkor commented Mar 24, 2019

Copy link
Copy Markdown

Приветствую! Спасибо за проделанную работу.
У меня появилась задача связанная с сервисом Dadata.ru, в поисках нашел ваш пакет.
Я изменил некоторые моменты в коде, приватный метод client(), добавил метода, поправил файл example.
Цель правки избавиться от пакета https. и использовать fetch.
Пожалуйста посмотрите изменения. Спасибо!

П.С.
Я не являюсь FrontEnd разработчиком, не судите строго, если что. Я немного комменты поправил, думается что должен быть пробел после описания метода

Comment thread index.js
}

module.exports = Dadata;
export default Dadata;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в этом случае не будет работать с node.js

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для совместимости с нодой и клиентской частью нужно делать экспорт по другому

module.exports = Dadata;
module.exports.default = Dadata;

Comment thread index.js
req.write(JSON.stringify(request));
req.end();
});
return fetch(this._path(api), options);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Желательно уже тут делать fetch-json

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так-же нужно добавить полифил node-fetch

Comment thread index.js
*/
_client(api, params) {
const request = Object.assign({
let request = Object.assign({

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let?

Comment thread index.js
count: 10
}, params);
const options = {
let options = {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let?

@mike1pol mike1pol added this to the v1.2.0 milestone Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants