小编Qin*_*iso的帖子

有没有办法将 [[Promise Result]] 保存为变量?

我正在尝试访问 [[Promise Results]] 并将其保存为变量。最终目标我只想要 .then 语句的结果并将其用于其他函数。如果有其他更好的方法,请告诉我,我是 JavaScript 新手,所以如果你能向我解释它而不仅仅是转储代码,那就太棒了。提前致谢 这是获取请求

function currentloginid() {
    return fetch('http://localhost/gaq/api/api.php?action=userid', {
       method: 'GET',
    })
    .then(function(response) {
        return response.json();
    })
    .then(function(data) {
        var userid = JSON.parse(data);
        console.log(userid);
        return userid;
    })
}
Run Code Online (Sandbox Code Playgroud)

下面的代码是当我在另一个函数中控制台记录该函数时的代码

Promise {<pending>}
__proto__: Promise
[[PromiseState]]: "fulfilled"
[[PromiseResult]]: 1
Run Code Online (Sandbox Code Playgroud)

javascript promise ecmascript-6

6
推荐指数
1
解决办法
6万
查看次数

如何创建 Avro 架构?

我想知道这个 json 文档的 Avro 模式是什么样的。

推文.json:

{
  "_id": {
    "$oid" : "54d148b471eb130b1e8b4567"
  },
  "nome": "Marco Correia",
  "tweet": "This and a simple tweet",
  "datahora": "Tue Feb 03 22:15:54 +0000 2015"
}
Run Code Online (Sandbox Code Playgroud)

我创建的架构给出了错误。

架构.avsc:

{
  "type" : "record",
  "name" : "twitter_schema",
  "namespace" : "com.miguno.avro",
  "fields" : [
    {
        "name" : "_id", "type": "array","items": "bytes"
    },

    { "name" : "nome","type" : "string","doc" : "Name of the user account on Twitter.com" },
    { "name" : "tweet", "type" : "string","doc" : "The content of the …
Run Code Online (Sandbox Code Playgroud)

apache json avro

5
推荐指数
1
解决办法
1087
查看次数

为什么当我想打开 minergate 控制台版本但它给我这个错误?

我试过安装Minergate console版本Ubuntu,当我想打开它但Terminal给我这个错误:

在抛出“spdlog::spdlog_ex” what() 实例后调用终止:名称为“core”的记录器已经存在中止(核心转储)。

ubuntu runtime-error bitcoin

4
推荐指数
1
解决办法
4777
查看次数

鼠标右键单击 p5.js 显示浏览器上下文菜单,而不是绘图功能

我在 P5.js 中有这个函数:

function mousePressed() {
    if (mouseButton === LEFT) {
        background(255);
        canvas2.clear();
        canvas3.clear();
    }
    if (mouseButton === RIGHT) {
        canvas3.clear();
        canvas3.fill(0, 0, 0);
        canvas3.stroke(0, 0, 0);
        canvas3.rect(80, 180, 40, 40);
    }
}
Run Code Online (Sandbox Code Playgroud)

它工作得很好,但是...当我单击鼠标右键时,会显示浏览器上下文菜单(将图像另存为...,复制图像...,检查 Ctrl+Shift+I)。如何禁用此功能或更改行为?

javascript mouseevent p5.js

3
推荐指数
1
解决办法
2815
查看次数