Created
February 15, 2022 00:20
-
-
Save lobot/c873889a04e5cc4497016f2975a73ae6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Configuration,Postcard, PostcardsApi, PostcardEditable | |
} from "@lob/lob-typescript-sdk"; | |
async function demo() { | |
const config: Configuration = new Configuration({ | |
username: "<YOUR_TEST_KEY>" | |
}); | |
const postcardData : PostcardEditable = { | |
to: { | |
name: "Harry Zhang", | |
address_line1: "210 King Street", | |
address_city: "San Francisco", | |
address_state: "CA", | |
address_zip: "94107" | |
}, | |
from: { | |
name: "Leore Avidar", | |
address_line1: "210 King Street", | |
address_city: "San Francisco", | |
address_state: "CA", | |
address_zip: "94107", | |
address_country: "US" | |
}, | |
front: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/4x6_pc_template.pdf", | |
back: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/4x6_pc_template.pdf" | |
} | |
try { | |
const postcard : Postcard = await new PostcardsApi(config).create(postcardData); | |
console.log('The Lob API responded with this postcard object: ', postcard); | |
} catch (err: any) { | |
console.error(err); | |
} | |
} | |
demo().then().catch(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment