Post method in ionic 3

ı got the error in postman like this 500Internal Server Error

Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'full_name' cannot be null (SQL: insert into students (full_name, email, password, updated_at, created_at)

and for give info my student table like this

protected $fillable=[‘full_name’,‘email’, ‘password’,‘phone_number’,‘author’] ı am not get phone number eg when make login . Is it make problem?

can you push your code to a repository and share so i can help you out?

laravel codes or ionic codes ?

the laravel codes. that’s the one you have issues with

allow cross origin in your laravel api
and then

 postData(credentials, type) {
    return new Promise<[any]>(resolve => {
      let headers = new Headers({ 'Content-Type': 'application/json' });
      let options = new RequestOptions({ headers: headers });, {credentials: credentials} , options)
        .subscribe(data => {
          if (data['status'] == 200) {
   = JSON.parse(data['_body']);
            // console.log(;
          else {
   = [];

Please check it @Tubiss

Things I disagree with in the previous post:

  • abuse of any
  • creation of needless Promise
  • needless headers and options
  • lack of typing for arguments and return values
  • multiple confusing parameters
  • creating and subscribing to a future in the same place
  • needless parsing of JSON
  • overly specific definition of success
  • ==
  • unnecessary index expression
  • encapsulation violation
  • lots of pointless verbiage

How I would write it instead:

type ThingyFlavor = "widget" | "frobulet";

interface Thingy<T extends ThingyFlavor> {
  id: string;
  flavor: T;
  name: string;
  // whatever else goes here

getThingies<T extends ThingyFlavor>(flavor: T): Observable<Thingy<T>[]> {
  return<Thingy<T>[]>(apiUrl+flavor, {credentials: this.credentials});

The credentials shouldn’t need to be provided by the caller; this service should be responsible for getting and holding them via some other method (like Storage or another service).