I’m trying to make a POST to this api https://cleanuri.com/docs, its returning status 200 OK, but with no response
<code>import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ShortenerService {
constructor(private http: HttpClient) {
}
private url = "https://cleanuri.com/api/v1/shorten"
getShorten(): Observable<any>{
const body = new URLSearchParams();
body.set('url', 'https://google.com');
const headers = new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded'
})
return this.http.post(this.url, body.toString(), {headers: headers})
}
}
</code>
<code>import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ShortenerService {
constructor(private http: HttpClient) {
}
private url = "https://cleanuri.com/api/v1/shorten"
getShorten(): Observable<any>{
const body = new URLSearchParams();
body.set('url', 'https://google.com');
const headers = new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded'
})
return this.http.post(this.url, body.toString(), {headers: headers})
}
}
</code>
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ShortenerService {
constructor(private http: HttpClient) {
}
private url = "https://cleanuri.com/api/v1/shorten"
getShorten(): Observable<any>{
const body = new URLSearchParams();
body.set('url', 'https://google.com');
const headers = new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded'
})
return this.http.post(this.url, body.toString(), {headers: headers})
}
}
<code> }
ngOnInit(): void {
this.shortenerService.getShorten().subscribe(x => {
console.log(x)
}, error => {
console.log("error:", error)
})
}
}
</code>
<code> }
ngOnInit(): void {
this.shortenerService.getShorten().subscribe(x => {
console.log(x)
}, error => {
console.log("error:", error)
})
}
}
</code>
}
ngOnInit(): void {
this.shortenerService.getShorten().subscribe(x => {
console.log(x)
}, error => {
console.log("error:", error)
})
}
}
status 200OK
blank response
I tried to change the Content-Type but didnt work.