0

I have 2 projects: one of them is an Angular frontend application, the other one, the backend, is a dynamic web project. My IDE is Eclipse. The following POST method is not working, I am getting in the Eclipse console null everytime the method runs. I just need to show in my console a string param.

POST method in Java:

@POST
    @Path("add")
    @Produces(MediaType.TEXT_PLAIN)
    public void addSelection(@FormParam("id") String id) {
        System.out.print(id);

    }

Service in Angular:

import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { HttpHeaders } from '@angular/common/http';
import { Headers, RequestOptions } from '@angular/http';


import { Observable } from 'rxjs';
import { catchError } from 'rxjs/operators';

//import { HttpErrorHandler, HandleError } from '../http-error-handler.service';


@Injectable()
export class App {


  constructor(private http: HttpClient){
  }

  addWord(word: string) {
        this.http.post('http://localhost:8080/***/add', word).subscribe();
  }

  }
Betelgeuse
  • 27
  • 1
  • 6

0 Answers0