Skip to content

Commit

Permalink
feat: reinstate product class, minor updates for AI demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Sep 13, 2024
1 parent b60a484 commit 755c4a5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion capture/get.request.http
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
GET /products/10 HTTP/1.1
GET /product/10 HTTP/1.1
Host: api.example.com
User-Agent: curl/8.1.2
Authorization: Bearer asetouhasnetuhasoetuaose
Accept: application/json; charset=UTF-8
2 changes: 2 additions & 0 deletions products.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ components:
type: string
price:
type: number
foobar:
type: boolean
12 changes: 2 additions & 10 deletions src/api.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const axios = require("axios").default;
const adapter = require("axios/lib/adapters/http");

const { Product } = require("./product");
axios.defaults.adapter = adapter;
axios.defaults.headers.common['Accept'] = "application/json";
axios.defaults.headers.common["Accept"] = "application/json; charset=utf-8";

export class API {
constructor(url) {
Expand Down Expand Up @@ -46,11 +46,3 @@ export class API {
.then((r) => new Product(r.data));
}
}

export class Product {
constructor({id, name, type}) {
this.id = id
this.name = name
this.type = type
}
}
8 changes: 8 additions & 0 deletions src/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export class Product {
constructor({id, name, type, foobar}) {
this.id = id
this.name = name
this.type = type
this.foobar = foobar
}
}

0 comments on commit 755c4a5

Please sign in to comment.