我有两个请求:一个是POST请求,另一个是get请求。首先,我通过邮寄方式获取用户访问令牌,在其他情况下,我使用此 accessToken 来登录。我的代码不起作用。
我使用的是window 7和cypress 3.3.5
我的代码:
var value;
describe("Login operation", () => {
it("Login Request with post method", () => {
cy.request({
method:'POST',
url:'https://odms.baitussalam.org:8445/api/v1/auth/login',
body: {
"userName": "faizanj",
"password": "abc"
}
})
.then(function(response){
this.value = response.body.accessToken;
console.log("Value "+this.value);
expect(response.body.name).to.equal('Faizan');
expect(response.status).to.equal(200);
});
});
it('Second test case', function() {
var authHeader='bearer ${'+this.value+'}';
const options = {
method: 'GET',
url: `https://odms.baitussalam.org:8445/api/v1/qurbani-representative`,
headers:{
authorization:authHeader,
}};
cy.request(options)
.then((response)=>{
expect(response.status).to.equal(200);6+9
});
});
});
Run Code Online (Sandbox Code Playgroud) 我有一个代码,负责裁剪图像并将其裁剪区域保存在div列表中。每个div代表每个裁剪的图像。但是问题是-我不希望它们太大,我希望它们具有fixed高度和宽度,例如max 100x100px。
具有有效图像裁剪功能的Codesandbox:https ://codesandbox.io/s/fast-frost-0b5tt 裁剪逻辑相关的代码:
const width = pos.w + "px";
const height = pos.h + "px";
const marginLeft = - pos.x + "px";
const marginTop = - pos.y + "px";
return (
<div
key={i}
style={{
width: width,
height: height,
backgroundSize: "400px 300px",
backgroundPosition: `top ${marginTop} left ${marginLeft}`,
backgroundImage: "url('https://boygeniusreport.files.wordpress.com/2016/11/puppy-dog.jpg?quality=98&strip=all&w=400')"
}}
/>
);
Run Code Online (Sandbox Code Playgroud)
您会看到图像裁剪效果很好,但是新创建的图像具有动态的高度和宽度。
问题:如何使这些新创建的div具有固定的宽度和高度,但又不破坏它?谢谢!
目的是使子代(裁剪的图像)具有固定的高度和宽度,但将背景图像保持在正确的位置。但似乎我太停顿了,不能自己做
尝试使用 dotnet 后端构建和运行 angular 项目时,我收到以下错误。
info: Microsoft.AspNetCore.SpaServices[0]
ERROR in ../../../../node_modules/@angular/common/common.d.ts(1208,17): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/@angular/common/common.d.ts(1271,42): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/@angular/common/common.d.ts(2423,26): error TS2304: Cannot find name 'unknown'.
../../../../node_modules/@angular/core/core.d.ts(214,21): error TS1039: Initializers are not allowed in ambient contexts.
../../../../node_modules/@angular/core/core.d.ts(5347,22): error TS1039: Initializers are not allowed in ambient contexts.
../../../../node_modules/@angular/core/core.d.ts(10292,36): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal.
../../../../node_modules/@angular/core/core.d.ts(10963,55): error TS1254: A 'const' initializer in an ambient context must be a …Run Code Online (Sandbox Code Playgroud) 项目是使用通用登录页面和密钥斗篷的较大站点的一部分。keycloak 脚本是所有页面都使用的布局的一部分。当未通过身份验证的用户到达页面时,它会正确地将其标识为“未通过身份验证”并发出警报。但它不会重定向到页面。
这是所有页面使用的基本布局中的脚本:
在此处输入代码
<script src="https://someplace.com/auth/js/keycloak.js"></script>
<script>
var keycloak = Keycloak({
url: 'https://someplace.com/auth',
realm: 'myrealm',
clientId: 'myclientid'
});
keycloak.init().success(function(authenticated) {
alert(authenticated ? 'authenticated' : 'not authenticated');
}).error(function() {
alert('failed to initialize');
});
</script>
Run Code Online (Sandbox Code Playgroud)
它给出了正确的警报“未通过身份验证”,但不会重定向到登录页面“ https://someplace.com/auth ”
javascript ×3
angular ×1
css ×1
cypress ×1
get ×1
keycloak ×1
networking ×1
okta ×1
reactjs ×1
request ×1