如何在静态发布的API drupal 8中发送链接和链接文本?

问题描述 投票:2回答:1

我可以使用发送链接

“ field_link”:{“ href”:“ http://www.news24headlines.com”},

但无法发送链接文本。我找不到与此有关的任何文档。

drupal drupal-modules drupal-8
1个回答
0
投票

您可以发送标题如下的链接:

        let body = {
          _links: {
            type: {
              href:
                "http://bo.mysite.docker.localhost/rest/type/node/candidats"
            }
          },
          title: [{ value: this.firstNameLastName }],
          field_entreprise_emploi_actuel: [{ value: this.company }],
          field_adresse_email: [{ value: this.email }],
          field_lien_linkedin: [
            {
              uri: "https://www.linkedin.com",
              title: "Linkedin",
              options: []
            }
          ],
          field_lien_github: [
            {
              uri: "https://github.com",
              title: "Github",
              options: []
            }
          ],
          field_lien_autre: [
            {
              uri: "https://gist.github.com/achraf-jeday",
              title: "Autre",
              options: []
            }
          ],
          field_pays: [{ value: this.country }],
          field_prenom_nom: [{ value: this.firstNameLastName }],
          field_telephone: [{ value: this.phone }],
          field_ville: [{ value: this.city }],
          type: [{ target_id: "candidats" }]
        };

        const username = "admin";
        const password = "admin";
        const basicAuthCredential = username + ":" + password;
        const bace64 = btoa(basicAuthCredential);
        const basic = "Basic " + bace64;
        let headers = {
          headers: {
            "Content-Type": "application/hal+json",
            "X-CSRF-Token": response.data.csrf_token,
            Authorization: basic,
            "Access-Control-Allow-Origin": "http://mysite.docker.localhost",
            "Access-Control-Allow-Credentials": "true"
          }
        };
        axios.post(
            `http://bo.dhmit.docker.localhost/entity/node?_format=hal_json`,
            body,
            headers
        )
        .then(response => {
          if (response.status === 200) {
          }
        })
        .catch(e => {
          this.errors.push(e);
        });
      }
    })
© www.soinside.com 2019 - 2024. All rights reserved.