HTTPPOST请求未被API打中,但POSTMAN正在使用相同的API

时间:2018-09-20 10:13:43

标签: asp.net api ionic-framework asp.net-web-api

我正在使用离子调用HTTPPOST方法,该API正在使用REST API测试工具POSTMAN,但是Angular POST Requset并未击中该API

下面的离子代码

TYPE_SYSTEM_OVERLAY

我的ASP.NET API代码如下所示

import { Injectable } from '@angular/core';
import { Http, Headers } from '@angular/http';
import 'rxjs/add/operator/map';
let apiUrl = 'http://localhost:52998/api/Default/login';

@Injectable()
export class AuthService {

  constructor(public http: Http) {}

  login(credentials) {
    debugger;
    return new Promise((resolve, reject) => {
        let headers = new Headers();
        headers.append('Content-Type', 'application/json');

        this.http.post(apiUrl+'AddEmployee', JSON.stringify(credentials), {headers: headers})
          .subscribe(res => {
            resolve(res.json());
          }, (err) => {
            reject(err);
          });
    });
  }

将API称为IONIC后,我会在上一次Debug的控制器名称上方看到Application Insight的增加,请帮我弄清楚,图像的屏幕截图位于:
The Screenshot of the image is here

0 个答案:

没有答案