Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70432

Argument of type 'Object' is not assignable to parameter of type 'string'

$
0
0

@mahirmersimoski wrote:

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

})

}

}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70432

Trending Articles



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