Skip to content

Commit

Permalink
Merge pull request #13 from MGalaCyber/master
Browse files Browse the repository at this point in the history
Fixed Cannot read properties of undefined (reading 'data')
  • Loading branch information
MGalaCyber authored Sep 9, 2024
2 parents d49f685 + 2ea967d commit 1e283e1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Full API Implementation inside NodeJS Module
- More info at [`Website`](https://api.universebot.space)
- Documentation [`Website`](https://docs.universebot.space)
- Get **API TOKEN** here [`Register`](https://api.universebot.space/register)
- _Free trial **premium** for `3 days` for new user._
- And you can upgrade your api token to premium, you can see more details at [`UPGRADE`](https://api.universebot.space/dashboard/pricing)

## Installation
npm:
Expand All @@ -29,7 +27,7 @@ $ pnpm add @mgalacyber/universeapi
```

## Simple to Use
## CommonJs (CJS) syntax
## CommonJS (CJS) syntax
```js
const { UniverseClient } = require("@mgalacyber/universeapi");
const uAPI = new UniverseClient("API-TOKEN");
Expand Down Expand Up @@ -57,5 +55,8 @@ uAPI.V1.AI.OpenAI.GPT.Text({
```


# Feedback
If you have any feedback, please reach out to us at `[email protected]`
# Bugs, Glitches and Issues
If you encounter any problems feel free to open an issue in our
- [GitHub Repository](https://github.com/UniverseBot/UniverseAPI-Wrapper/issues)
- [Telegram Group](https://t.me/GalaxyUniverseOfficial)
- [Discord Server](https://discord.gg/uESnRWjEwv)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mgalacyber/universeapi",
"version": "3.4.5",
"version": "3.4.8",
"description": "UniverseAPI Wrapper package endpoint",
"main": "index.js",
"typings": "./typings/index.d.ts",
Expand Down
13 changes: 12 additions & 1 deletion src/method.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ class Method {

return getResponse.data;
} catch (error) {
return error.response.data;
if (error && error.response) {
return error.response.data;
} else {
return {
status: false,
code: 500,
speed: "0ms",
author: "@GXD",
message: error.message || "An unknown error occurred",
data: null
}
}
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/v1/AI/TextToImage.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
module.exports = function(Api) {
return {
Generate: async function(options) {
const { version, prompt } = options;
const { model, version, prompt } = options;

return (await Api()).Get(`v1/ai/text2img/model${version}`, { prompt });
if (model && model.length > 0) {
return (await Api()).Get(`v1/ai/text2img/model${version}`, { prompt, model });
} else {
return (await Api()).Get(`v1/ai/text2img/model${version}`, { prompt });
}
}
}
};
1 change: 1 addition & 0 deletions typings/v1/AI/TextToImage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Result from "../../utils/Result";
export interface GenerateOptions {
version: number;
prompt: string;
model?: string;
}

/**
Expand Down

0 comments on commit 1e283e1

Please sign in to comment.