我是Node js的新手。请告诉我如何使用此节点客户端https://www.npmjs.com/package/serp。
const serp = require("serp");
var options = {
host : "google.fr",
qs : {
q : "test",
filter : 0,
pws : 0
},
num : 100
};
const links = await serp.search(options);当我运行这个代码时,我会收到以下错误
SyntaxError:等待仅在异步函数中有效
非常感谢大家的帮助!
发布于 2022-01-30 11:21:37
这允许函数中的await属性,并允许代码在前进之前等待任务完成。
声明异步函数的示例:
// Declare the function
async function search() {
// Run asynchronous code
const serp = require("serp");
var options = {
host : "google.fr",
qs : {
q: "test",
filter: 0,
pws: 0
},
num : 100
};
const links = await serp.search(options);
}
// Run the function
search();https://stackoverflow.com/questions/70913767
复制相似问题