1

I have important question, please help me as soon as possible

when im testing laravel part by postman - api works well unfortunetly on front i got problems with it. its like angular try to connect with api on 4200 port no 8000.

  • Welcome to SO .. you need to take a look https://stackoverflow.com/questions/34516651/set-base-url-for-angular-2-http-requests – Kamlesh Paul Sep 29 '20 at 09:14
  • Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange network, you've granted a non-revocable right, under the [CC BY-SA 4.0 license](//creativecommons.org/licenses/by-sa/4.0/), for Stack Exchange to distribute that content (i.e. regardless of your future choices). By Stack Exchange policy, the non-vandalized version of the post is the one which is distributed. Thus, any vandalism will be reverted. If you want to know more about deleting a post please see: [How does deleting work?](//meta.stackexchange.com/q/5221) – Machavity Sep 30 '20 at 13:02
  • Please add code and data as text ([using code formatting](//stackoverflow.com/editing-help#code)), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and [many more reasons](//meta.stackoverflow.com/a/285557). Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data. – Machavity Sep 30 '20 at 13:06

1 Answers1

0

You create code like that...

    import { Injectable, EventEmitter } from '@angular/core';
    import { HttpClient } from '@angular/common/http';
    import { Observable } from 'rxjs';
    
    @Injectable({
      providedIn: 'root'
    })
    export class FileService {
    
      refressFileList: EventEmitter<string> = new EventEmitter();
    
      constructor(
        private http: HttpClient
      ) { }

getBooks(): Observable<Book[]> {
        return this.http
            .get<Book[]>('http://www.localhost:8000/api/books')
            .pipe(catchError(this.handleError('getBooks', [])));
    }
    
      getData(params: any): Observable<any> {
        return this.http.get<any>('http://www.localhost:8000/api/books', params);
      }
    }
Bharat Chauhan
  • 3,204
  • 5
  • 39
  • 52