What the cause of this error :
Argument of type ‘Object’ is not assignable to parameter of type ‘string’.
This is the code:
import { Component, OnInit } from ‘@angular/core’;
import { HttpClient } from ‘@angular/common/http’;
@Component({
selector: ‘app-uploader’,
templateUrl: ‘./uploader.page.html’,
styleUrls: [’./uploader.page.scss’],
})
export class UploaderPage implements OnInit {
imageURL: string
constructor(public http: HttpClient) { }
ngOnInit() {
}
fileChanged(event) {
const files = event.target.files
const data = new FormData()
data.append('file', files[0])
data.append('UPLOADCARE_STORE', '1')
data.append('UPLOADCARE_PUB_KEY', 'my key')
this.http.post('https://upload.uploadcare.com/base/', data).subscribe(event => {
console.log(event)
this.imageURL = JSON.parse(event).file <<<<<<< HERE i get the error in the (event) when i try to parse it with JSON
})
}
}