가 여기 내 서버 측 코드각도 : 게시물 또는 요청을 입력 한 후 http 코드를 확인하는 방법은 무엇입니까?
[HttpPut("api/columnInfoData")]
public IActionResult UpdateColumnInfoData([FromBody] KeyValue[] columnInfoList)
{
try
{
_unit.ColumnInfos
.UpdateColumnInfoData(columnInfoList);
_unit.SaveChanges();
return NoContent();
}
catch (Exception ex)
{
return BadRequest();
}
}
입니다 그리고 이것은 내 각도 코드입니다 .. 불행하게도
updateColumnInfos(){
this._backendService
.updateColumnInfos("api/columnInfoData", this.tempColumnIdList)
.subscribe(success => {
if(success){
}
}, err => this.errorMessage = "failed to update column selection")
//this.reloadTable = false;
}
updateColumnInfos(_url: string, body) {
return this.http.put(this.baseUrl + _url, body)
//.do(data => console.log('getKeyValues: ' + JSON.stringify(data)))
.map((event: HttpEvent<any>) =>{
console.log(event.type)
})
.catch(this.handleError);
}
이 구독 부분, 그건 아무것도 로깅하지 않습니다. 내 C# 코드에 중단 점을 넣을 때 중단 점이 맞고 있습니다. Postman
을 통해 요청을하면 204
이 표시됩니다.
내 각형 코드의 코드를 확인하는 방법은 무엇입니까? 사실 성공적인 열 업데이트 후에 테이블을 다시로드하려고합니다. 편집
돕는
감사
대신 return NoConent()
, 내가 return Ok("Test...");
를 반환하고있어,하지만 내 각 코드는 여전히 아무것도를 기록하지 않습니다. 내가 브라우저에 갈 때, : F12 > Network tab > Response tab
, 지금은 로그인 한 것, 대신 익명 객체 Ok(obj)
를 만드는 문자열 Ok("test...")
을 반환하는 Test...
편집 2
를 참조하십시오. 어떤 이유가 있습니까?
public IActionResult UpdateColumnInfoData([FromBody] KeyValue[] columnInfoList)
{
try
{
_unit.ColumnInfos
.UpdateColumnInfoData(columnInfoList);
_unit.SaveChanges();
//return Ok("test..."); --> I've changed this to ..
var resp = new { resp = "test..." };
return Ok(resp);
}
catch (Exception ex)
{
return BadRequest();
}
}
각 버전? 이 httpclient 또는 http 서비스입니까? – bryan60
구독 하시겠습니까? 포함 된 코드는 실제로 http 요청을하지 않습니다. – Steveland83
패키지에 json이있다 :'^ 5.0.0' 그리고 이것은 '@ angular/common/http'의'import {HttpClient} ';' – Richard77