用http和axios分别发送请求
用http发送请求
效果
这个请求网址是可以用的:https://api.xygeng.cn/one
代码
import http from '@ohos.net.http';
class Book {
id: string
tag: string
name: string
origin: string
content: string
created_at: Date
updated_at: Date
error: object
updateTime: number
constructor(id: string, tag: string, name: string, origin: string, content: string, created_at: Date,
updated_at: Date, error: object, updateTime: number) {
this.id = id
this.tag = tag
this.name = name
this.origin = origin
this.content = content
this.created_at = created_at
this.updated_at = updated_at
this.error = error
this.updateTime = updateTime
}
}
class R {
code: number;
data: Book;
constructor(code:number,book:Book) {
this.code = code
this.data = book
}
}
@Entry
@Component
struct HttpDemoPage {
@State message: string = 'Hello World';
@State book:Book = new Book('id','tag','name','origin'