1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Pass csrf meta tag with angular 4 when using laravel as API only

Discussão em 'Angular' iniciado por ivva, Outubro 16, 2024.

  1. ivva

    ivva Guest

    I'm using Laravel 5.5 and Angular 4. Laravel is only as an API. I'm trying to pass the data from a form and I can't pass the csrf token. Here's my service:

    import { ElementRef, Injectable, Injector, Renderer2, ViewChild } from '@angular/core';
    import { HttpClient } from '@angular/common/http';
    import { Observable } from 'rxjs/Observable';
    import { Link } from './link.model';
    import 'rxjs/Rx';
    import { RequestOptions } from '@angular/http';

    @Injectable()
    export class LinkService {

    constructor(private http: HttpClient) {

    }

    createLink(link): Observable<any> {
    //links param is the data from the form

    let url = 'http://127.0.0.1:8000/links';
    return this.http
    .post(url, link)
    .map(response => {
    console.log(response);
    })
    }
    }


    I've removed the VerifyCsrfToken middleware from the App/Kernel.php so there is no error now. But if somebody knows if it is possible to pass it, please let me know.

    Continue reading...

Compartilhe esta Página