add headers in network plugin
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "DoricNetworkPlugin.h"
|
||||
#include "engine/DoricPromise.h"
|
||||
#include "utils/DoricNetworkService.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -9,10 +10,20 @@ void DoricNetworkPlugin::request(QString jsValueString, QString callbackId) {
|
||||
QJsonDocument document = QJsonDocument::fromJson(jsValueString.toUtf8());
|
||||
QJsonValue jsValue = document.object();
|
||||
|
||||
DoricNetworkService::getInstance()->request(jsValue, qApp,
|
||||
[](int code, QByteArray data) {
|
||||
qDebug() << code;
|
||||
qDebug() << data;
|
||||
qDebug() << "";
|
||||
});
|
||||
DoricNetworkService::getInstance()->request(
|
||||
jsValue, qApp,
|
||||
[this, callbackId](int code, QList<QByteArray> headers, QByteArray data) {
|
||||
getContext()->getDriver()->asyncCall(
|
||||
[this, callbackId, code, headers, data] {
|
||||
QMap<QString, QVariant> map;
|
||||
map.insert("status", code);
|
||||
map.insert("headers", QVariant::fromValue(headers));
|
||||
map.insert("data", QString(data));
|
||||
|
||||
QVariantList args;
|
||||
args.append(map);
|
||||
DoricPromise::resolve(getContext(), callbackId, args);
|
||||
},
|
||||
DoricThreadMode::JS);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user