我的 hashkey 是一个名为 pid 的数字
这是代码
app.get('/register', (req, res) => {
var params = {
TableName:"passengers",
Item: {
"pid": 55
}
};
console.log("Adding a new item...");
docClient.put(params, function(err, data) {
if (err) {
console.log("errrrrrrr");
console.error("Unable to add item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("succccccc");
console.log("Added item:", JSON.stringify(data, null, 2));
}
});
console.log("Added a new item...");
res.send('<h1>some html</h1>');
})
Run Code Online (Sandbox Code Playgroud)
errrrr 或 succcc 都不会打印在日志中,但会打印“添加新项目”和“添加新项目”。
我找了一个关于这个的stackoverflow但是找不到办法去做.它可能涉及itertools.
我想找到分割字符串的所有可能结果,比如将字符串thisisateststring分成n(等长或不等长,无关紧要,两者都应包括在内)字符串.
例如,让n是3:
[["thisisat", "eststrin", "g"], ["th", "isisates", "tstring"], ............]
Run Code Online (Sandbox Code Playgroud) int gcd(int x, int y) {
int t;
while (y) {
t = x;
x = y;
y = t % y;
}
return x;
}
Run Code Online (Sandbox Code Playgroud)
当y = 0时它会停止吗?我认为当y未定义时循环停止.
我想使用 jest.fn().mockimplementation() 来模拟 fetch 函数,并使用 jest.fn().mockimplementation() 进行额外的 blob 提取,而不使用 fetch-mock 或 jest-fetch-mock
fetch(url)
.then((response) => response.blob)
.then((data) => imageHandler(data))
Run Code Online (Sandbox Code Playgroud) 您好,我希望它InstrumentPage在#/访问时以无道具的形式呈现,但在#/ipb访问通过时ipb作为props实体。但这不起作用。
render() {
return (<React.Fragment>
<HashRouter>
<Switch>
<Route path='/' render={(props) => <InstrumentPage {...props} />}/>
{Object.keys(AppConfig).forEach((property) =>
<Route path={property} render={(props) => <InstrumentPage {...props} entity={property} />} />)
}
</Switch>
</HashRouter>
</React.Fragment>);
}
Run Code Online (Sandbox Code Playgroud)
AppConfig
const AppConfig = {
pb: {
header: 'PBHeader',
body: 'PBBody',
},
ipb: {
header: 'IPBHeader',
body: 'IPBBody',
},
};
export default AppConfig;
Run Code Online (Sandbox Code Playgroud) javascript ×2
reactjs ×2
c ×1
chunks ×1
ecmascript-6 ×1
express ×1
fetch ×1
jestjs ×1
list ×1
python ×1
react-router ×1
string ×1