Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49290

415 (Unsupported Media Type)

$
0
0

hi I try postdata have been error 415 Unsupported Media Type :slight_smile:

  1. how to solve this case.
  2. how to add application/json on my typescript as below
    import { HttpClient, HttpHeaders } from ‘@angular/common/http’;

import { Injectable } from ‘@angular/core’;

import { environment } from ‘…/…/environments/environment’;

@Injectable({

providedIn: ‘root’

})

export class HttpService {

headers = new HttpHeaders();

// options = { headers: this.headers, withCredintials: false };

options = { headers: this.headers };

constructor(private http: HttpClient) {}

post(serviceName: string, data: any) {

console.log("data asli:", JSON.stringify(data));

const url = environment.apiUrl + serviceName;

return this.http.post(url, JSON.stringify(data), this.options);

}

}

thank you

4 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 49290

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>