Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 发送带有查询参数的帖子时出错_Angular_Typescript_Http - Fatal编程技术网

Angular 发送带有查询参数的帖子时出错

Angular 发送带有查询参数的帖子时出错,angular,typescript,http,Angular,Typescript,Http,我需要发出这个帖子请求,我通过param发送邮件,但是我没有收到。我看到了类似的问题并尝试实施,但仍然没有成功 我的api:http://localhost:8080/auth/reset-密码?电子邮件=myemail@email.com sendEmail() { const email = this.loginForm.get('email').value; this.loginService.sendEmail(email) .s

我需要发出这个帖子请求,我通过param发送邮件,但是我没有收到。我看到了类似的问题并尝试实施,但仍然没有成功

我的api:http://localhost:8080/auth/reset-密码?电子邮件=myemail@email.com

sendEmail() {
        const email = this.loginForm.get('email').value;
    
        this.loginService.sendEmail(email)
        .subscribe(() => {
            alert('ok');
        },
        erro => {
            alert('error');
            this.loginForm.reset();
        })
        
    }

服务:

sendEmail(email: string) {
        let params = new HttpParams();
        params = params.append('email', email);
        console.log(params)
        
        return this.http.post(API_URL + 'reset-password?',{params: params});
    }


您的API需要get,而不是post:
返回此.http.get(API_URL+'reset-password?email='+email)
-如果确实使用post,请使用与此.http.post相同URL的post(API_URL+'reset password?',{},{params:params});是正确的格式。@MikeOne-tks,有效。您的API需要get,而不是post:
返回此.http.get(API_URL+'reset-password?email='+email)
-如果确实使用post,请使用与此相同URL的post.http.post(API_URL+'reset-password?,{},{params:params});是正确的格式。@MikeOne tks,有效。