Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get link from server response #21

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ Link Tool supports these configuration parameters:

## Output data

This Tool returns `data` with following format
This Tool returns `data` with following format:

| Field | Type | Description |
| -------------- | --------- | ------------------------------- |
| link | `string` | Pasted link url |
| link | `string` | Pasted or fetched link url |
| meta | `object` | Fetched link data. Any data got from backend. Currently title, image and description are supported by plugin's design. |

```json
Expand Down Expand Up @@ -115,12 +115,15 @@ Backend response **should** cover following format:

**success** — uploading status. 1 for successful, 0 for failed

**meta** — link fetched data.
**link** — pasted link can be updated (e.g. after redirects)

Currently title, image and description fields are supported by plugin's design . They should have the following format in the response:
**meta** — link fetched data

Currently **link**, **title**, **image** and **description** fields are supported by plugin's design. They should have the following format in the response:
```json5
{
"success" : 1,
"link": "https://codex.so",
"meta": {
"title" : "CodeX Team",
"description" : "Club of web-development, design and marketing. We build team learning how to build full-valued projects on the world market.",
Expand Down
2 changes: 1 addition & 1 deletion dist/bundle.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,9 @@ export default class LinkTool {
}

const metaData = response.meta;
const link = response.link;

this.data = { meta: metaData };
this.data = { link: link, meta: metaData };

if (!metaData) {
this.fetchingFailed('Wrong response format from server');
Expand Down