我正在尝试访问 [[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) 我想知道这个 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) 我试过安装Minergate console版本Ubuntu,当我想打开它但Terminal给我这个错误:
在抛出“spdlog::spdlog_ex” what() 实例后调用终止:名称为“core”的记录器已经存在中止(核心转储)。
我在 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 ×2
apache ×1
avro ×1
bitcoin ×1
ecmascript-6 ×1
json ×1
mouseevent ×1
p5.js ×1
promise ×1
ubuntu ×1