0

I am working on Aspnet Core Angular project and getting following error:

TS2304: Cannot find name 'email'.

The code is executed in visual studio 2017.

postEmailValidate(email?: string): Observable<any> {
    var data: {
        "Email": email,
        "Timeout": "5",
        "Verbose": "True"
    };        
    return this.http.post(
        this.urlEmailValidate,
        data,
        { headers: this.getHeaders("POST") }
        )
        //.delay(5000)
        .map(this.handleSuccess)
        .catch(this.handleError)
}

The code is very basic and I have declared a variable in the function's call. But the compiler gives the following error. Am I forgetting something or is it a visual studio issue? enter image description here enter image description here

2 Answers 2

1

You just have a wrong syntax for object delcaration. Replace var data: with var data =

var data = {
    "Email": email,
    "Timeout": "5",
    "Verbose": "True"
};
Sign up to request clarification or add additional context in comments.

1 Comment

My bad :P. Thanks alot for the answer
1

You need to assign values to data:

var data = {
    "Email": email,
    "Timeout": "5",
    "Verbose": "True"
};  

1 Comment

Thanks alot for the answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.