Javascript angular 5 http.put请求返回错误“;未提供身份验证凭据";

Javascript angular 5 http.put请求返回错误“;未提供身份验证凭据";,javascript,angular,http,angular5,put,Javascript,Angular,Http,Angular5,Put,我想使用Http put方法更新用户信息,但它不断返回 detail: "Authentication credentials were not provided 这是我的editComponent.ts export class MyProfileEditComponent implements OnInit { store: any = {}; editProfileForm: FormGroup; private formSubmitAttempt: boolea

我想使用Http put方法更新用户信息,但它不断返回

detail: "Authentication credentials were not provided
这是我的editComponent.ts

export class MyProfileEditComponent implements OnInit {
    store: any = {};
    editProfileForm: FormGroup;
    private formSubmitAttempt: boolean;

    constructor(fb: FormBuilder, public storeSrv: StoreService) {
        this.editProfileForm = fb.group({
            'mobile': [''],
            'address': [''],
            'description': [''],
            'storeUserId': [''],
    });
}

editProfile() {
   this.formSubmitAttempt = true;
   if (this.store.mobile || this.store.address || this.store.description) {
   this.storeSrv.editStore(this.store.mobile, this.store.address, this.store.description, this.store.storeUserId);
   }
 }
}
还有我的storeService.ts代码

@Injectable()
export class StoreService {
 public updateStoreUrl = this.globals.UPDATE_STORE_URL
 store: any = {};
 storeId: any;

 constructor(private http: Http, private router: Router, private globals: Globals) { }

 editStore(mobile: string, address: string, description: string, storeId: any) {
    let tempStore = localStorage.getItem('store');
    if (tempStore) {
      this.store = JSON.parse(tempStore);
      this.storeId = this.store.user;
    }

    let headers = new Headers();
    headers.append('Content-Type', 'application/json');
    return this.http.put(this.updateStoreUrl + this.storeId + '/', { 
    headers })
       .subscribe(res => {
          let msg = JSON.parse(res['_body'])['message'];
       }, error => {
          let msg = JSON.parse(error._body)['message'];
       })
   };
我想知道我哪里弄错了,因为api端点在请求中期望storeId…在我看来一切都很好,但再一次…你能帮我发现错误或引导我走正确的道路吗

使用editComponent.html更新

<form [formGroup]="editProfileForm" (ngSubmit)="editProfile()" novalidate>
                <div class="row">
                  <div class="col-md-6">
                    <div class="form-group has-feedback" style="position: relative;">
                      <label for="storename">Store Name</label>
                      <input type="text" name="storename" class="form-control" placeholder="{{store.name}}" disabled>
                    </div>
                  </div>

                  <div class="col-md-6">
                    <div class="form-group has-feedback" style="position: relative;">
                      <label for="mobilenumber">Mobile Number</label>
                      <input type="text" name="mobilenumber" class="form-control" placeholder="{{store.mobile}}" [(ngModel)]="store.mobile" [formControl]="editProfileForm.controls['mobile']">
                    </div>
                  </div>

                  <div class="col-md-6">
                    <div class="form-group has-feedback" style="position: relative;">
                      <label for="address">Store Address</label>
                      <textarea name="address" id="" cols="30" rows="10" class="form-control" placeholder="{{store.address1}}"></textarea>
                    </div>
                  </div>

                  <div class="col-md-6">
                    <div class="form-group has-feedback" style="position: relative">
                      <label for="description">Store Description</label>
                      <textarea name="description" id="" cols="30" rows="10" class="form-control" placeholder="{{store.description}}"></textarea>
                    </div>
                  </div>

                  <input type="text" name="storeUserId" [(ngModel)]="store.userId" [formControl]="editProfileForm.controls['storeUserId']" value="{{store.user}}" hidden>

                  <div class="btn-container" style="float: right; margin-right: 15px;">
                    <button class="btn btn-accent btn-flat b-r-10">Edit Profile</button>
                  </div>
                </div>
              </form>

店名
手机号码
存储地址
商店描述
编辑配置文件

您在哪里提供凭据?我在任何地方都看不到它给我一分钟lemme update@Miketung为什么不使用http拦截器并在那里提供授权凭据@您发送的链接中的ChristianBenseler使用的是HttpClient,但我使用的是Http,它会是相同的用例吗?@CE0您应该转到
HttpClient
,因为
Http
在最新版本中已被弃用