Skip to content

Commit

Permalink
🦉 Updates from OwlBot post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] committed Oct 9, 2024
1 parent 2a15e6e commit 0c06961
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ npm install @google-cloud/pubsub

```javascript
// Imports the Google Cloud client library
const { PubSub } = require("@google-cloud/pubsub");
const {PubSub} = require('@google-cloud/pubsub');

async function quickstart(
projectId = 'your-project-id', // Your Google Cloud Platform project ID
topicNameOrId = 'my-topic', // Name for the new topic to create
subscriptionName = 'my-sub' // Name for the new subscription to create
projectId = 'your-project-id', // Your Google Cloud Platform project ID
topicNameOrId = 'my-topic', // Name for the new topic to create
subscriptionName = 'my-sub' // Name for the new subscription to create
) {
// Instantiates a client
const pubsub = new PubSub({ projectId });
const pubsub = new PubSub({projectId});

// Creates a new topic
const [topic] = await pubsub.createTopic(topicNameOrId);
Expand All @@ -84,19 +84,19 @@ subscriptionName = 'my-sub' // Name for the new subscription to create
const [subscription] = await topic.createSubscription(subscriptionName);

// Receive callbacks for new messages on the subscription
subscription.on('message', (message) => {
subscription.on('message', message => {
console.log('Received message:', message.data.toString());
process.exit(0);
});

// Receive callbacks for errors on the subscription
subscription.on('error', (error) => {
subscription.on('error', error => {
console.error('Received error:', error);
process.exit(1);
});

// Send a message to the topic
topic.publishMessage({ data: Buffer.from('Test message!') });
topic.publishMessage({data: Buffer.from('Test message!')});
}

```
Expand Down

0 comments on commit 0c06961

Please sign in to comment.